Total Pageviews

Friday, 21 October 2016

搭建基于hakyll的静态博客程序secure.plaimi.net

先按此文http://briteming.blogspot.com/2016/07/hakyll.html,安装ghc和hakyll.
cd /usr/local
git clone https://github.com/plaimi/www secure.plaimi.net
cd secure.plaimi.net

root@AR:/usr/local/secure.plaimi.net# ls
about.markdown      favicon.ico      other              

~alexander      games          other.markdown      
games.markdown  papers          site.hs
Config.hi      images      papers.markdown      

Config.hs      index.html      presentations          swag.markdown
Config.o      mailing.html      presentations.markdown  templates
contact.markdown  news          projects.markdown      works
css          news.markdown   README          works.markdown
~emil          ~olle         

root@AR:/usr/local/secure.plaimi.net#  ghc --make site.hs (此命令会在当前目录下,生成可执行文件site)
root@AR:/usr/local/secure.plaimi.net# ls
about.markdown      favicon.ico      other              

~alexander      games          other.markdown     
_cache          games.markdown  papers          site.hs
Config.hi      images      papers.markdown     

Config.hs      index.html      presentations          swag.markdown
Config.o      mailing.html      presentations.markdown  templates
contact.markdown  news          projects.markdown      works
css          news.markdown   README          works.markdown
~emil          ~olle          site
root@AR:/usr/local/secure.plaimi.net# ./site build (此即为生成静态网站的根目录的命令)

(在运行它时,会遇错:
[ERROR] ./presentations/2014-08-20-tempuhs-chronology-visualisation.markdown: YAML parse exception at line 2, column 14:
mapping values are not allowed in this context
Hint: if the metadata value contains characters such
as ':' or '-', try enclosing it in quotes.
root@AR:/usr/local/secure.plaimi.net#


解决办法:
root@AR:/usr/local/secure.plaimi.net# cd presentations
root@AR:/usr/local/secure.plaimi.net/presentations# rm *.md
root@AR:/usr/local/secure.plaimi.net/presentations# cd ..
root@AR:/usr/local/secure.plaimi.net# ./site build 
或者把/usr/local/secure.plaimi.net/presentations/里的所有的markdown文件里的title的值加上英文单音号/双引号。)

root@AR:/usr/local/secure.plaimi.net# ls
about.markdown      favicon.ico      other              _site
~alexander      games          other.markdown      site.hi
_cache          games.markdown  papers          site.hs
Config.hi      images      papers.markdown      site.o
Config.hs      index.html      presentations          swag.markdown
Config.o      mailing.html      presentations.markdown  templates
contact.markdown  news          projects.markdown      works
css          news.markdown   README          works.markdown
~emil          ~olle          site

(生成了_site目录)
root@AR:/usr/local/secure.plaimi.net# cd _site

root@AR:/usr/local/secure.plaimi.net/_site# ls
about.html    games        news    papers            swag.html
~alexander    games.html    news.html    papers.html        works
contact.html  images        ~olle    presentations        works.html
css          index.html    other    presentations.html
~emil          mailing.html  other.html    projects.html
root@AR:/usr/local/secure.plaimi.net/_site#  

(可见/usr/local/secure.plaimi.net/_site就是静态网站的根目录)

新建源帖:
root@AR:/usr/local/secure.plaimi.net/_site# cd ..
root@AR:/usr/local/secure.plaimi.net# cd news

root@AR:/usr/local/secure.plaimi.net/news# nano 2016-10-21-test-1.markdown
root@AR:/usr/local/secure.plaimi.net/news# cat 2016-10-21-test-1.markdown
---
title: 测试1
---

这是测试1.

root@AR:/usr/local/secure.plaimi.net/news# cd ..

root@AR:/usr/local/secure.plaimi.net# ./site build

演示网站:http://pm.bright.biz.st,
项目地址:https://github.com/plaimi/www