Total Pageviews

Tuesday 23 August 2016

搭建基于hakyll的静态博客程序blog.dshevchenko.biz

先安装ghc和cabal.

cd /usr/local
git clone https://github.com/denisshevchenko/blog blog.dshevchenko.biz
cd blog.dshevchenko.biz

root@AR:/usr/local/blog.dshevchenko.biz# ls
blog.cabal       deploy.sh      posts src
cabal.sandbox.config  dist     README.md stack.yaml
_cache       just_build.sh  Setup.hs static
CNAME       LICENSE     templates

root@AR:/usr/local/blog.dshevchenko.biz# cabal sandbox init
root@AR:/usr/local/blog.dshevchenko.biz# cabal install
(运行完成后,会生成.cabal-sandbox/bin/目录)
root@AR:/usr/local/blog.dshevchenko.biz# cd .cabal-sandbox/bin/
root@AR:/usr/local/blog.dshevchenko.biz/.cabal-sandbox/bin# ls
aeson-pretty  blog  hakyll-init  json2yaml  pandoc  pandoc-citeproc  yaml2json
(blog就是可执行文件)
root@AR:/usr/local/blog.dshevchenko.biz/.cabal-sandbox/bin# cd ../..
root@AR:/usr/local/blog.dshevchenko.biz# .cabal-sandbox/bin/blog build (此即生成/更新静态网站的命令)
root@AR:/usr/local/blog.dshevchenko.biz# ls
blog.cabal       deploy.sh      posts src
cabal.sandbox.config  dist     README.md stack.yaml
_cache       just_build.sh  Setup.hs static
CNAME       LICENSE     _site templates
root@AR:/usr/local/blog.dshevchenko.biz# cd _site
root@AR:/usr/local/blog.dshevchenko.biz/_site# ls
2013  archive.html  feed.xml README.md    static  tags.html
2016  CNAME     index.html sitemap.xml  tags
root@AR:/usr/local/blog.dshevchenko.biz/_site#
(可见/usr/local/blog.dshevchenko.biz/_site/就是静态网站的根目录)

新建源贴:
root@AR:/usr/local/blog.dshevchenko.biz/_site# cd ..
root@AR:/usr/local/blog.dshevchenko.biz# cd posts
root@AR:/usr/local/blog.dshevchenko.biz/posts# rm *.md
root@AR:/usr/local/blog.dshevchenko.biz/posts# nano 2016-08-23-1709-test-1.md
root@AR:/usr/local/blog.dshevchenko.biz/posts# cat 2016-08-23-1709-test-1.md
---
title: 测试1
tags: misc1, misc2, misc3
---

这是测试1.
root@AR:/usr/local/blog.dshevchenko.biz/posts# cd ..
root@AR:/usr/local/blog.dshevchenko.biz# .cabal-sandbox/bin/blog build

演示网站:http://surmount.biz.st:4193,http://dsck.smt.biz.st
项目地址:https://github.com/denisshevchenko/blog