Pages

Saturday, 17 December 2016

搭建基于haskell的静态博客程序pbrisbin.com

首先按此文http://briteming.blogspot.jp/2016/07/hakyll.html安装stack,ghc.

cd /usr/local
git clone https://github.com/pbrisbin/pbrisbin.com
cd pbrisbin.com

root@AR:/usr/local/pbrisbin.com# ls
_cache     css LICENSE  Makefile  README.md  site.cabal  stack.yaml
circle.yml  favicon.ico  main.hs  posts     src   templates
root@AR:/usr/local/pbrisbin.com# stack build
会显示:
...
Linking .stack-work/dist/i386-linux/Cabal-1.22.5.0/build/site/site ...
site-0.0.0: copy/register
Installing library in
/usr/local/pbrisbin.com/.stack-work/install/i386-linux/lts-5.0/7.10.3/lib/i386-linux-ghc-7.10.3/site-0.0.0-Ax2tiLQZrhxHq1Pd7VQX1G
Installing executable(s) in
/usr/local/pbrisbin.com/.stack-work/install/i386-linux/lts-5.0/7.10.3/bin
Registering site-0.0.0...
Completed 122 action(s).
root@AR:/usr/local/pbrisbin.com# .stack-work/dist/i386-linux/Cabal-1.22.5.0/build/site/site rebuild (此即生成/更新静态网站的根目录的命令)
root@AR:/usr/local/pbrisbin.com# ls
_cache     css LICENSE  Makefile  README.md  site.cabal  stack.yaml
circle.yml  favicon.ico  main.hs  posts     _site      src   templates
(生成了_site目录)
root@AR:/usr/local/pbrisbin.com# ls _site
archives  css  favicon.ico  feed  index.html  posts  tags
root@AR:/usr/local/pbrisbin.com#
root@AR:/usr/local/pbrisbin.com# cd _site
root@AR:/usr/local/pbrisbin.com/_site# ls
archives  css  favicon.ico  feed  index.html  posts  tags
(可见/usr/local/pbrisbin.com/_site就是静态网站的根目录)

新建源帖:

root@AR:/usr/local/pbrisbin.com/_site# cd ..
root@AR:/usr/local/pbrisbin.com# cd posts
root@AR:/usr/local/pbrisbin.com/posts# nano 2016-12-17-test-1.md
root@AR:/usr/local/pbrisbin.com/posts# cat 2016-12-17-test-1.md
---
title: 测试1
tags: misc1, misc2, misc3
---

这是测试1.

看看如何?
root@AR:/usr/local/pbrisbin.com/posts# cd ..
root@AR:/usr/local/pbrisbin.com# .stack-work/dist/i386-linux/Cabal-1.22.5.0/build/site/site rebuild

演示网站:http://pb.bright.biz.st
项目地址:https://github.com/pbrisbin/pbrisbin.com