Total Pageviews

Saturday 20 August 2016

搭建基于hakyll的静态博客程序AustinRochford-blog

先安装ghc/cabal和hakyll.
cd /usr/local
git clone https://github.com/AustinRochford/blog AustinRochford-blog
cd AustinRochford-blog

root@AR:/usr/local/AustinRochford-blog# ls
blog.cabal  LICENSE   provision.sh  Vagrantfile
_cache     Makefile  README.md     static
index.html  site.hs       templates

root@AR:/usr/local/AustinRochford-blog# ghc --make site.hs
root@AR:/usr/local/AustinRochford-blog# ls
blog.cabal  LICENSE   provision.sh  site.o Vagrantfile
_cache     Makefile  README.md     site.hi  static
index.html  site     site.hs  templates
root@AR:/usr/local/AustinRochford-blog# ./site build
root@AR:/usr/local/AustinRochford-blog# ls
blog.cabal  LICENSE   provision.sh  _site    site.o Vagrantfile
_cache     Makefile  README.md     site.hi  static
index.html  site     site.hs  templates
(生成了_site目录)
root@AR:/usr/local/AustinRochford-blog# cd _site
root@AR:/usr/local/AustinRochford-blog/_site# ls
404.html    css index.html  posts.html    rss.xml  tags.html
about.html  favicon.ico  posts     reading.html  tags
root@AR:/usr/local/AustinRochford-blog/_site# 
(可见/usr/local/AustinRochford-blog/_site/就是静态网站的根目录)

新建源贴:
root@AR:/usr/local/AustinRochford-blog/_site# cd ..
root@AR:/usr/local/AustinRochford-blog# mkdir posts (这个博客程序的作者大概担心别人克隆他的帖子。在其源码仓库里,干脆删除了posts目录.所以我们需要自己创建posts目录)
root@AR:/usr/local/AustinRochford-blog# cd posts
root@AR:/usr/local/AustinRochford-blog/posts# nano 2016-08-20-2247-test-1.md
root@AR:/usr/local/AustinRochford-blog/posts# cat 2016-08-20-2247-test-1.md
---
title: 测试1
tags: misc1, misc2, misc3
---

这是测试1.
root@AR:/usr/local/AustinRochford-blog/posts# cd ..
root@AR:/usr/local/AustinRochford-blog# ./site build

演示网站:http://surmount.biz.st:3294,首页只显示最近的帖子,我修改静态网站的根目录里的index.html文件,在其中的head区插入跳转代码:<meta http-equiv="refresh" content="0; url=/posts.html"> ,以便让http://surmount.biz.st:3294跳转到http://surmount.biz.st:3294/posts.html
http://ar.smt.biz.st,http://austinrochford.com/posts.html(程序作者搭建的网站)
项目地址:https://github.com/AustinRochford/blog