Total Pageviews

Wednesday 9 November 2016

搭建基于hakyll的静态博客程序nicolerauch.de

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

cd /usr/local
git clone https://github.com/NicoleRauch/BusinessWebsite nicolerauch.de
cd nicolerauch.de


root@AR:/usr/local/nicolerauch.de# cd hakyll
root@AR:/usr/local/nicolerauch.de/hakyll# ghc --make site.hs
root@AR:/usr/local/nicolerauch.de/hakyll# ls
blog.html     posts       StringManipulation.hi
css     referenzen.html    StringManipulation.hs
data     robots.txt       StringManipulation.o
images (not directly used)  schwerpunkte.html  StringManipulationTest.hs
img     site       templates
impressum.html     site.hi       termine.html
index.html     site.hs       themen.html
kommende-neu.json     site.o
nicole.cabal     stack.yaml
(生成了可执行文件site)
root@AR:/usr/local/nicolerauch.de/hakyll# ./site build (此即为生成静态网站的根目录的命令)
如果显示:
...
[ERROR] ./templates/post.html: hGetContents: invalid argument (invalid byte sequence)
这其实是因为_cache目录变得
corrupted而造成的,解决办法:
root@AR:/usr/local/nicolerauch.de/hakyll# ./site clean && ./site build 
(或者运行./site rebuild也可。./site rebuild等效于./site clean && ./site build)
root@AR:/usr/local/nicolerauch.de/hakyll# cd ..
root@AR:/usr/local/nicolerauch.de# 
那么生成的静态网站的根目录在哪里呢?
root@AR:/usr/local/nicolerauch.de# find . -name index.html
./HTML/index.html
./hakyll/index.html
root@AR:/usr/local/nicolerauch.de# cd ./HTML
root@AR:/usr/local/nicolerauch.de/HTML# ls
blog.html  impressum.html  referenzen.html    termine.html
css   index.html   robots.txt       themen.html
img   posts   schwerpunkte.html
root@AR:/usr/local/nicolerauch.de/HTML# ls posts
2010-09-22-autoboxing-is-evil.html
2010-12-19-story-point-estimation.html
2011-11-16-setter-machen-objekte-kaputt.html
2012-02-28-software-development-and-focus.html
2012-03-04-setters-destroy-objects.html
2012-09-13-the-eve-of-the-socrates-conference.html
2015-04-15-retrospective-prime-directive-eine-alternative.html
2015-10-19-einfuhrung-in-die-funktionale-programmierung.html
2015-10-29-socrates-germany.html
2015-12-20-lightweight-stubbing-of-ajax-requests-in-javascript.html
2016-05-16-shallow-rendering.html
2016-08-29-craftsman-swap-and-journeyman-tour.html
2016-11-09-test-1.html
root@AR:/usr/local/nicolerauch.de/HTML#
(/usr/local/nicolerauch.de/HTML/posts/里全是html文件,这些html文件都是由md文件转化而来。所以就知道
/usr/local/nicolerauch.de/HTML/就是静态网站的根目录)

新建源帖:
root@AR:/usr/local/nicolerauch.de/HTML# cd ../hakyll/posts
root@AR:/usr/local/nicolerauch.de/hakyll/posts# nano 2016-11-09-test-1.md
root@AR:/usr/local/nicolerauch.de/hakyll/posts# cat 2016-11-09-test-1.md
---
layout: post
author: brite fisher
title: 测试1
lang: en
---

这是测试1.

看看如何?
root@AR:/usr/local/nicolerauch.de/hakyll/posts# 
root@AR:/usr/local/nicolerauch.de/hakyll/posts# cd ..
root@AR:/usr/local/nicolerauch.de/hakyll# ./site build
root@AR:/usr/local/nicolerauch.de/hakyll# cd ../HTML
root@AR:/usr/local/nicolerauch.de/HTML# rm index.html (删除当前目录下的index.html)
root@AR:/usr/local/nicolerauch.de/HTML# mv blog.html index.html (然后把blog.html重命名为index.html)

演示网站:http://nr.bright.biz.st
项目地址:https://github.com/NicoleRauch/BusinessWebsite