Total Pageviews

Saturday, 20 August 2016

搭建基于hakyll的静态博客程序hblog

首先安装ghc和hakyll.
cd /usr/local
git clone https://github.com/Abizern/hblog hblog-site
cd hblog-site

root@AR:/usr/local/hblog-site# ls
about.markdown favicon.png  humans.txt   posts   talks
_cache images      README.markdown  templates
CNAME index.html   robots.txt
css hblog.hs     LICENSE.txt  scripts
favicon.ico notes   

root@AR:/usr/local/hblog-site# ghc --make hblog.hs
root@AR:/usr/local/hblog-site# ls
about.markdown favicon.png  humans.txt   posts   talks
_cache hblog     images   README.markdown  templates
CNAME hblog.hi     index.html   robots.txt
css hblog.hs     LICENSE.txt  scripts
favicon.ico hblog.o      notes
(生成了可执行文件hblog)   
root@AR:/usr/local/hblog-site# ./hblog build (这个就是生成/更新静态网站的根目录的命令)
root@AR:/usr/local/hblog-site# ls
about.markdown favicon.png  humans.txt   posts   talks
_cache hblog     images   README.markdown  templates
CNAME hblog.hi     index.html   robots.txt
css hblog.hs     LICENSE.txt  scripts
favicon.ico hblog.o      notes   _site
(生成了_site目录)
root@AR:/usr/local/hblog-site# cd _site
root@AR:/usr/local/hblog-site/_site# ls
2009  2013  2106      CNAME favicon.ico  index.html  talks
2010  2014  about     cocoa-coding-conventions favicon.png  notes
2011  2015  archive   css humans.txt   robots.txt
2012  2016  atom.xml  emacs-notes images     tags
root@AR:/usr/local/hblog-site/_site# 
(可见/usr/local/hblog-site/_site/就是静态网站的根目录)

新建源贴:
root@AR:/usr/local/hblog-site/_site# cd ..
root@AR:/usr/local/hblog-site# cd posts
root@AR:/usr/local/hblog-site/posts# nano 2016-08-21-1351-test-1.markdown
root@AR:/usr/local/hblog-site/posts# cat 2016-08-21-1351-test-1.markdown
---
title: 测试1
tags: misc1, misc2, misc3
---

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

演示网站:http://surmount.biz.st:4219,http://hblog.smt.biz.st
项目地址:https://github.com/Abizern/hblog