Total Pageviews

Thursday 3 November 2016

搭建基于hakyll的静态博客程序bneijt.nl

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

cd /usr/local
git clone https://github.com/bneijt/bneijt.nl
cd bneijt.nl
rm hakyll (先删除快捷方式hakyll)
ghc --make hakyll.hs
第一次运行此命令,会遇错。见https://github.com/bneijt/bneijt.nl/issues/1。解决办法:
修改hakyll.hs文件如下-
删除此行:

import System.Locale (defaultTimeLocale)
然后加上此行:
import Data.Time.Format (formatTime, defaultTimeLocale)

再次运行ghc --make hakyll.hs ,就不会遇错了。会在当前目录下,生成可执行文件hakyll。
./hakyll build (这就是生成/更新静态网站的根目录的命令)

root@AR:/usr/local/bneijt.nl# ls
blog hakyll     hakyll.o   rebuild.sh  src
bneijt-nl.cabal  hakyll.hi  LICENSE    Setup.hs    static
_cache hakyll.hs  README.md  _site   templates
(生成了目录_site)
root@AR:/usr/local/bneijt.nl# cd _site
root@AR:/usr/local/bneijt.nl/_site# ls
blog  css  img index.html  js robots.txt
root@AR:/usr/local/bneijt.nl/_site#

(可见/usr/local/bneijt.nl/_site就是静态网站的根目录)

新建源贴:
root@AR:/usr/local/bneijt.nl/_site# cd ../blog/post/
root@AR:/usr/local/bneijt.nl/blog/post# ls
my-first-post 
root@AR:/usr/local/bneijt.nl/blog/post# mkdir test-1
root@AR:/usr/local/bneijt.nl/blog/post# nano test-1/index.markdown
(按my-first-post/index.markdown文件的内容格式,新建源贴test-1/index.markdown如下:
---
title: 测试1
published: 2016-11-03
author: brite fisher
---

这是测试1.

看看如何呢? )
root@AR:/usr/local/bneijt.nl/blog/post# cd ../..
root@AR:/usr/local/bneijt.nl# ./hakyll build

演示网站:http://bnj.bright.biz.st/blog, https://bneijt.nl/blog/
项目地址:https://github.com/bneijt/bneijt.nl