Total Pageviews

Sunday, 21 August 2016

搭建基于hakyll的静态博客程序sadhen.com和xinitrc.de

先安装ghc环境。

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

root@AR:/usr/local/sadhen.com-site# ls
about.html    css   Plugins    templates    
archive.html  index.html  README.md  springer-lncs.csl
blog       LICENSE   ref.bib    static
_cache       partials   scripts    site.hs  

root@AR:/usr/local/sadhen.com-site# ghc --make site.hs
root@AR:/usr/local/sadhen.com-site# ls
about.html    css   Plugins    site     site.o
archive.html  index.html  README.md  springer-lncs.csl
blog       LICENSE   ref.bib    site.hi  static
_cache       partials   scripts    site.hs  templates
root@AR:/usr/local/sadhen.com-site# apt-get install ruby-sass ruby-compass yui-compressor
root@AR:/usr/local/sadhen.com-site# ./site build
会显示:
...
[ERROR] Missing field $posts$ in context for item index.html

解决办法:
root@AR:/usr/local/sadhen.com-site# nano index.html
(把index.html里的$posts$那一行删除)
root@AR:/usr/local/sadhen.com-site# ./site build
root@AR:/usr/local/sadhen.com-site# ls 
about.html    css   Plugins    site     site.o
archive.html  index.html  README.md  _site    springer-lncs.csl
blog       LICENSE   ref.bib    site.hi  static
_cache       partials   scripts    site.hs  templates
root@AR:/usr/local/sadhen.com-site# cd _site
root@AR:/usr/local/sadhen.com-site/_site# ls
about.html     assets    css     image tags
adaptive-images.php  atom.xml  favicon.ico  index.html
archive.html     blog      fonts     scripts
root@AR:/usr/local/sadhen.com-site/_site#
(可见/usr/local/sadhen.com-site/_site/就是静态网站的根目录)

新建源贴:
root@AR:/usr/local/sadhen.com-site/_site# cd ..
root@AR:/usr/local/sadhen.com-site# ls
about.html    css   Plugins    site     site.o
archive.html  index.html  README.md  _site    springer-lncs.csl
blog       LICENSE   ref.bib    site.hi  static
_cache       partials   scripts    site.hs  templates
root@AR:/usr/local/sadhen.com-site# cd blog
root@AR:/usr/local/sadhen.com-site/blog# nano 2016-08-22-0849-test-1.md
root@AR:/usr/local/sadhen.com-site/blog# cat 2016-08-22-0849-test-1.md
---
title: 测试1
tags: misc1, misc2, misc3
---

这是测试1.
root@AR:/usr/local/sadhen.com-site/blog# cd ..
root@AR:/usr/local/sadhen.com-site# ./site build

演示网站:http://surmount.biz.st:7425/,http://sh.smt.biz.st
项目地址:https://github.com/sadhen/sadhen.com
---------------

上面这个程序fork自https://github.com/xinitrc/xinitrc.de

搭建基于hakyll的静态博客程序xinitrc.de
cd /usr/local
git clone https://github.com/xinitrc/xinitrc.de --depth=1
cd xinitrc.de

root@AR:/usr/local/xinitrc.de# ls
archive.html   css     Plugins    springer-lncs.csl  templates
basic       gulpfile.js  README.md  static   xinitrcde.cabal
blog       index.html   ref.bib    talk-archive.html
bower.json     LICENSE     scripts    talks
compressJS.sh  partials     site.hs    talks.html
root@AR:/usr/local/xinitrc.de# 
root@AR:/usr/local/xinitrc.de# ghc --make site.hs
root@AR:/usr/local/xinitrc.de# ls
archive.html   css     Plugins    site.hi   talk-archive.html
basic       gulpfile.js  README.md  site.hs   talks
blog       index.html   ref.bib    site.o   talks.html
bower.json     LICENSE     scripts    springer-lncs.csl  templates
compressJS.sh  partials     site       static   xinitrcde.cabal
(生成了可执行文件site)
root@AR:/usr/local/xinitrc.de# ./site build
root@AR:/usr/local/xinitrc.de# ls
archive.html   css     README.md  site.hs   talks.html
basic       gulpfile.js  ref.bib    site.o   templates
blog       index.html   scripts    springer-lncs.csl  xinitrcde.cabal
bower.json     LICENSE     site       static
_cache       partials     _site      talk-archive.html
compressJS.sh  Plugins     site.hi    talks
root@AR:/usr/local/xinitrc.de# cd _site
root@AR:/usr/local/xinitrc.de/_site# ls
about.html  archive.html  assets  atom.xml  blog  contact.html index.html
root@AR:/usr/local/xinitrc.de/_site#
(可见/usr/local/xinitrc.de/_site/就是静态网站的根目录)

新建源贴:
root@AR:/usr/local/xinitrc.de/_site# cd ..
root@AR:/usr/local/xinitrc.de# cd blog
root@AR:/usr/local/xinitrc.de/blog# nano 2016-08-22-1033-test-1.md
root@AR:/usr/local/xinitrc.de/blog# cat 2016-08-22-1033-test-1.md
---
title: 测试1
tags: misc1, misc2, misc3
---

这是测试1.
root@AR:/usr/local/xinitrc.de/blog# cd ..
root@AR:/usr/local/xinitrc.de# ./site build
会显示:
...
[ERROR] Missing field $posts$ in context for item index.html

解决办法:
root@AR:/usr/local/xinitrc.de# nano index.html
(把index.html里的$posts$那一行删除)
root@AR:/usr/local/xinitrc.de# ./site build (这次就正常了)

演示网站:http://surmount.biz.st:4872/,http://surmount.biz.st:4872/archive.html
http://xnt.smt.biz.st,http://xnt.smt.biz.st/archive.html (这个博客程序带了一些js文件,网站打开的速度较慢)
项目地址:https://github.com/xinitrc/xinitrc.de