Total Pageviews

Wednesday, 24 August 2016

搭建基于hakyll的静态博客程序nek0.eu

先安装ghc和cabal.

cd /usr/local
git clone https://github.com/nek0/nek0.eu nek0.eu-site
cd nek0.eu-site

root@AR:/usr/local/nek0.eu-site# ls
404.md       css     images     posts stack.yaml
about.md       D7665688.txt  imprint.md     README.md templates
cabal.sandbox.config  dist     index.md     robots.txt
_cache       font     nek0-blog.cabal  src
contact.md       humans.txt    newpost.sh     
root@AR:/usr/local/nek0.eu-site# cabal sandbox init
root@AR:/usr/local/nek0.eu-site# cabal install
(运行完成后,会在子目录.cabal-sandbox/bin/下面生成可执行文件blog)
root@AR:/usr/local/nek0.eu-site# .cabal-sandbox/bin/blog build(此即生成/更新静态网站的命令)
root@AR:/usr/local/nek0.eu-site#
(运行.cabal-sandbox/bin/blog build时,会遇到错误。帖子2014-01-14-Now-new:-Syntax-highlighting!.md的文件名有问题。删除之,即可:
root@AR:/usr/local/nek0.eu-site# rm 'posts/2014-01-14-Now-new:-Syntax-highlighting!.md'
root@AR:/usr/local/nek0.eu-site# .cabal-sandbox/bin/blog build (这次运行成功)
root@AR:/usr/local/nek0.eu-site# ls
404.md       css     images     posts stack.yaml
about.md       D7665688.txt  imprint.md     README.md templates
cabal.sandbox.config  dist     index.md     robots.txt
_cache       font     nek0-blog.cabal  _site
contact.md       humans.txt    newpost.sh     src

root@AR:/usr/local/nek0.eu-site# cd _site
root@AR:/usr/local/nek0.eu-site/_site# ls
404.html      atom.xml     D7665688.txt  images posts     tags
about.html    contact.html  font   imprint.html robots.txt
archive.html  css     humans.txt   index.html rss.xml
root@AR:/usr/local/nek0.eu-site/_site# 
(可见/usr/local/nek0.eu-site/_site/就是静态网站的根目录)

新建源贴:
root@AR:/usr/local/nek0.eu-site/_site# cd ../posts
root@AR:/usr/local/nek0.eu-site/posts# nano 2016-08-25-0817-test-1.md
root@AR:/usr/local/nek0.eu-site/posts# cat 2016-08-25-0817-test-1.md
---
title: 测试1
author: brite
tags: misc1, misc2, misc3
description: xyz
---

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

演示网站:http://n0.smt.biz.st,http://surmount.biz.st:7538
项目地址:https://github.com/nek0/nek0.eu