Total Pageviews

Tuesday 17 January 2017

搭建基于haskell的静态博客程序stephendiehl.com

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

cd /usr/local
git clone https://github.com/sdiehl/stephendiehl.com
cd  stephendiehl.com

root@AR:/usr/local/stephendiehl.com# stack build
会显示:
...
Linking .stack-work/dist/i386-linux/Cabal-1.22.4.0/build/build/build ...
stephendiehl-0.1.0.0: copy/register
Installing executable(s) in
/usr/local/stephendiehl.com/.stack-work/install/i386-linux/lts-3.16/7.10.2/bin
Completed 127 action(s).
root@AR:/usr/local/stephendiehl.com#
root@AR:/usr/local/stephendiehl.com# ls .stack-work/install/i386-linux/lts-3.16/7.10.2/bin
build
(.stack-work/install/i386-linux/lts-3.16/7.10.2/bin/目录下的build文件就是可执行文件)
root@AR:/usr/local/stephendiehl.com# .stack-work/install/i386-linux/lts-3.16/7.10.2/bin/build build
(这就是生成/更新静态网站的根目录的命令。第二个build是参数。)
root@AR:/usr/local/stephendiehl.com# ls
LICENSE    _cache         hakyll.hs  posts
Makefile   _site         images     stack.yaml
README.md  cabal.sandbox.config  index.md   stephendiehl.cabal
Setup.hs   css             pages        templates
(生成了_site目录)
root@AR:/usr/local/stephendiehl.com#  cd _site
root@AR:/usr/local/stephendiehl.com/_site# ls
css  feed.atom    feed.rss  images  index.html  pages  posts  posts.html
root@AR:/usr/local/stephendiehl.com/_site#
(可见/usr/local/stephendiehl.com/_site就是静态网站的根目录)

新建源帖:
root@AR:/usr/local/stephendiehl.com/_site# cd ..
root@AR:/usr/local/stephendiehl.com#
root@AR:/usr/local/stephendiehl.com# cd posts
root@AR:/usr/local/stephendiehl.com/posts# nano test-1.md
root@AR:/usr/local/stephendiehl.com/posts# cat test-1.md
---
title: 测试1
date: January 17, 2017
---

这是测试1。

看看如何?

root@AR:/usr/local/stephendiehl.com/posts#
(我之后新建的源帖名分别为test-2.md,uchinese-economy.md,vbcoz-i-love-u.md;这是因为posts目录里,源帖从上到下的排列顺序为数字从小到大,字母从a到z.在同一天的帖子里,越排在下面的帖子在发表后,越显示在页面的上方。)
root@AR:/usr/local/stephendiehl.com/posts# cd ..
root@AR:/usr/local/stephendiehl.com# .stack-work/install/i386-linux/lts-3.16/7.10.2/bin/build build

演示网站:http://sd.bright.biz.st, http://sd.bright.biz.st/posts.html
项目地址:https://github.com/sdiehl/stephendiehl.com

No comments:

Post a Comment