Total Pageviews

Friday 18 November 2016

搭建基于hakyll的静态博客程序jjduhamel blog

先按此文http://briteming.blogspot.com/2016/07/hakyll.html,搭建stack,ghc,hakyll.
运行stack --version ,如果显示Version 1.1.2,说明你搭建stack的时间比较早,stack的版本较老,于是:
rm /usr/local/bin/stack
curl -sSL https://get.haskellstack.org/ | sh (重新安装stack)
这样安装出来的stack的版本为目前的最新版1.2.0,这样下面运行stack build时,就不会遇错。
(否则可能会遇到这里https://github.com/jjduhamel/blog/issues/1所述的错误)

cd /usr/local
git clone https://github.com/jjduhamel/blog/  jjduhamel-blog
cd  jjduhamel-blog

root@AR:/usr/local/jjduhamel-blog# ls
about.md    css         images      posts    site.hs
blog.cabal  design.html  index.html  README.md    stack.yaml

fonts     js         emplates
root@AR:/usr/local/jjduhamel-blog#  stack build

会显示:
...
 Linking .stack-work/dist/i386-linux/Cabal-1.22.5.0/build/site/site ...
  blog-0.1.0.0: copy/register
  Installing executable(s) in
  /usr/local/jjduhamel-blog/.stack-work/install/i386-linux/lts-6.8/7.10.3/bin

...
root@AR:/usr/local/jjduhamel-blog# gem install sass (须先安装ruby环境)
root@AR:/usr/local/jjduhamel-blog# gem install scss
root@AR:/usr/local/jjduhamel-blog# gem install compass
root@AR:/usr/local/jjduhamel-blog# .stack-work/dist/i386-linux/Cabal-1.22.5.0/build/site/site build (这个就是生成/更新静态网站的根目录的命令)
root@AR:/usr/local/jjduhamel-blog# ls
about.md    css         images      posts    site.hs
blog.cabal  design.html  index.html  README.md    stack.yaml
_cache        fonts     js         _site    templates

(生成了_site目录)
root@AR:/usr/local/jjduhamel-blog# cd _site

root@AR:/usr/local/jjduhamel-blog/_site# ls
about.html    css       fonts   index.html  posts
archive.html  design.html  images  js
root@AR:/usr/local/jjduhamel-blog/_site#

(可见_site目录就是静态网站的根目录)

新建源帖:
root@AR:/usr/local/jjduhamel-blog/_site# cd ..
root@AR:/usr/local/jjduhamel-blog# cd posts
root@AR:/usr/local/jjduhamel-blog/posts# nano 2016-11-18-test-1.md

root@AR:/usr/local/jjduhamel-blog/posts# cat 2016-11-18-test-1.md
---
title: 测试1
author: brite fisherman
---

这是测试1.

看看如何?

root@AR:/usr/local/jjduhamel-blog/posts# cd ..

root@AR:/usr/local/jjduhamel-blog# .stack-work/dist/i386-linux/Cabal-1.22.5.0/build/site/site build

演示网站:http://jb.bright.biz.st
项目地址: https://github.com/jjduhamel/blog
https://github.com/jjduhamel/blog/issues/1