Total Pageviews

Sunday 21 August 2016

搭建基于hakyll的静态博客程序kyle.marek-spartz.org

先安装ghc和stack.

cd /usr/local
git clone https://github.com/zeckalpha/kyle.marek-spartz.org
cd kyle.marek-spartz.org

root@AR:/usr/local/kyle.marek-spartz.org# ls
404.md  colophon.md   kyle-marek-spartz-org.cabal README.md
about.md  css   LICENSE.md robots.txt
build_css.sh  echo_sitemap.sh  new_post.py salem
build_cv.sh  favicon.ico   now.md site.hs
build_sitemap.sh  files   posts stack.yaml
_cache  images   presentations templates
check.sh  keybase.txt   publications
(这里,运行ghc --make site.hs所得到的可执行文件site不正常。因为另外还有stack.yaml文件,于是运行stack build来生成该博客程序的可执行文件)
root@AR:/usr/local/kyle.marek-spartz.org# stack build
显示:
...
Linking .stack-work/dist/i386-linux/Cabal-1.22.4.0/build/site/site ...
kyle-marek-spartz-org-0.1.0.0: copy/register
Installing executable(s) in
/usr/local/kyle.marek-spartz.org/.stack-work/install/i386-linux/lts-3.2/7.10.2/bin
Completed 31 action(s).
root@AR:/usr/local/kyle.marek-spartz.org# .stack-work/dist/i386-linux/Cabal-1.22.4.0/build/site/site build (此即生成/更新静态网站的命令)
显示:
...
[ERROR] Hakyll.Core.Compiler.Require.load: css/combined.css (snapshot _final) was not found in the cache, the cache might be corrupted or the item you are referring to might not exist
root@AR:/usr/local/kyle.marek-spartz.org#

解决办法:
root@AR:/usr/local/kyle.marek-spartz.org# cat build_css.sh
cat css/syntax.css css/default.css css/site.css > css/combined.css
root@AR:/usr/local/kyle.marek-spartz.org# cat css/syntax.css css/default.css css/site.css > css/combined.css
root@AR:/usr/local/kyle.marek-spartz.org# .stack-work/dist/i386-linux/Cabal-1.22.4.0/build/site/site build (这次就运行成功了)
root@AR:/usr/local/kyle.marek-spartz.org# ls
404.md   colophon.md   kyle-marek-spartz-org.cabal README.md
about.md   css   LICENSE.md robots.txt
build_css.sh   echo_sitemap.sh  new_post.py salem
build_cv.sh   favicon.ico   now.md _site
build_sitemap.sh  files   posts site.hs
_cache   images   presentations stack.yaml
check.sh   keybase.txt   publications templates
(生成了_site目录)
root@AR:/usr/local/kyle.marek-spartz.org# cd _site
root@AR:/usr/local/kyle.marek-spartz.org/_site# ls
404.html      blog.html      images   now.html   README.html
about.html    colophon.html  index.html    posts   robots.txt
atom-all.xml  favicon.ico    keybase.txt   presentations  salem
atom.xml      files     LICENSE.html  publications

root@AR:/usr/local/kyle.marek-spartz.org/_site#
(可见/usr/local/kyle.marek-spartz.org/_site/就是静态网站的根目录)

新建源贴:
root@AR:/usr/local/kyle.marek-spartz.org/_site# cd ..
root@AR:/usr/local/kyle.marek-spartz.org# cd posts
root@AR:/usr/local/kyle.marek-spartz.org/posts# nano 2016-08-22-0814-test-1.md
root@AR:/usr/local/kyle.marek-spartz.org/posts# cat 2016-08-22-0814-test-1.md
---
title: 测试1
tags: misc1, misc2, misc3
description: 测试
---

这是测试1.
(注意:这里,源贴里面的description: 测试这行不可少,否则之后会遇错
root@AR:/usr/local/kyle.marek-spartz.org/posts# cd ..
root@AR:/usr/local/kyle.marek-spartz.org# .stack-work/dist/i386-linux/Cabal-1.22.4.0/build/site/site build 

演示网站:http://surmount.biz.st:8736/,http://surmount.biz.st:8736/blog.html
http://kms.smt.biz.st,http://kms.smt.biz.st/blog.html
项目地址:https://github.com/zeckalpha/kyle.marek-spartz.org