Total Pageviews

Sunday, 21 August 2016

搭建基于hakyll的静态博客程序duplode.github.io

先安装stack.

cd /usr/local
git clone --branch sources https://github.com/duplode/duplode.github.io (此命令的意思是克隆sources分支)
cd duplode.github.io

root@AR:/usr/local/duplode.github.io# ls
build-hs.sh  duplode-github-io.cabal  README.md  stack.yaml
_cache     full-build.sh       Setup.hs src synchronise.sh
root@AR:/usr/local/duplode.github.io# stack build
Downloaded nightly-2015-07-19 build plan.  
Compiler version mismatched, found ghc-7.10.3 (i386), but expected minor version match with ghc-7.10.1

运行stack --resolver ghc-7.10.1 setup来安装此程序所需要的ghc版本:ghc-7.10.1
然后运行stack build (耗时33分钟)
root@AR:/usr/local/duplode.github.io# stack build
显示:
...
Linking .stack-work/dist/i386-linux/Cabal-1.22.2.0/build/duplode-github-io/duplode-github-io ...
duplode-github-io-0.1.0.0: copy/register
Installing executable(s) in
/usr/local/duplode.github.io/.stack-work/install/i386-linux/nightly-2015-07-19/7.10.1/bin
Completed 140 action(s).
root@AR:/usr/local/duplode.github.io# .stack-work/dist/i386-linux/Cabal-1.22.2.0/build/duplode-github-io/duplode-github-io build (此即生成/更新静态网站的命令)
root@AR:/usr/local/duplode.github.io# ls
build-hs.sh  duplode-github-io.cabal  README.md  _site stack.yaml
_cache     full-build.sh      Setup.hs src synchronise.sh
(生成了_site目录)
root@AR:/usr/local/duplode.github.io# cd _site
root@AR:/usr/local/duplode.github.io/_site# ls
about.html  extras  index.html posts.html  rss.xml
css    images  posts README.md
root@AR:/usr/local/duplode.github.io/_site#
(可见/usr/local/duplode.github.io/_site/就是静态网站的根目录)

新建源贴:
root@AR:/usr/local/duplode.github.io/_site# cd ..
root@AR:/usr/local/duplode.github.io# 
root@AR:/usr/local/duplode.github.io# cd src
root@AR:/usr/local/duplode.github.io/src# ls
about.md  extras     images posts     repo site.hs    uc.md
css   fragments  index.html  posts.html  Scripts.hs  templates
root@AR:/usr/local/duplode.github.io/src# cd posts
root@AR:/usr/local/duplode.github.io/src/posts# nano test-1.md
root@AR:/usr/local/duplode.github.io/src/posts# cat test-1.md
---
title: 测试1
published: 2016-08-21T19:31:00-03:00
---

这是测试1.
root@AR:/usr/local/duplode.github.io/src/posts# cd ../..
root@AR:/usr/local/duplode.github.io# .stack-work/dist/i386-linux/Cabal-1.22.2.0/build/duplode-github-io/duplode-github-io build

演示网站:http://surmount.biz.st:5328,http://dld.smt.biz.st
项目地址:https://github.com/duplode/duplode.github.io/tree/sources