Total Pageviews

Friday 16 December 2016

搭建基于haskell的静态博客程序da-x-hakyll-site

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

cd /usr/local
git clone https://github.com/da-x/hakyll-site da-x-hakyll-site
cd da-x-hakyll-site

root@AR:/usr/local/da-x-hakyll-site# ls
alonid-site.cabal  provider     Setup.hs  src
readme.markdown  site      stack.yaml

root@AR:/usr/local/da-x-hakyll-site# stack build
会显示:
...
Linking .stack-work/dist/i386-linux/Cabal-1.22.5.0/build/site/site ...
Copying executable 'site' to current directory...
alonid-site-1.0: copy/register
Installing executable(s) in
/usr/local/da-x-hakyll-site/.stack-work/install/i386-linux/lts-5.2/7.10.3/bin
Completed 93 action(s).
root@AR:/usr/local/da-x-hakyll-site# .stack-work/dist/i386-linux/Cabal-1.22.5.0/build/site/site rebuild (此即生成/更新静态网站的根目录的命令)
root@AR:/usr/local/da-x-hakyll-site# ls
alonid-site.cabal  provider     Setup.hs  src
generated   readme.markdown  site      stack.yaml
(生成了generated目录)
root@AR:/usr/local/da-x-hakyll-site# cd generated
root@AR:/usr/local/da-x-hakyll-site/generated# ls
deploy scss
root@AR:/usr/local/da-x-hakyll-site/generated# cd deploy
root@AR:/usr/local/da-x-hakyll-site/generated/deploy# ls
cache  out
root@AR:/usr/local/da-x-hakyll-site/generated/deploy# cd out
root@AR:/usr/local/da-x-hakyll-site/generated/deploy/out# ls
404.html  atom.xml  css     index.html notes  rss.xml
about   contact   images  js posts  static
root@AR:/usr/local/da-x-hakyll-site/generated/deploy/out#
(可见/usr/local/da-x-hakyll-site/generated/deploy/out就是静态网站的根目录。你可绑定域名到该目录)

新建源帖:
root@AR:/usr/local/da-x-hakyll-site/generated/deploy/out# cd /usr/local/da-x-hakyll-site
root@AR:/usr/local/da-x-hakyll-site# 
root@AR:/usr/local/da-x-hakyll-site# ls
alonid-site.cabal  provider     Setup.hs  src
generated   readme.markdown  site      stack.yaml
root@AR:/usr/local/da-x-hakyll-site# ls provider
drafts images js  pages  posts  scss static templates
root@AR:/usr/local/da-x-hakyll-site# ls src
pig.py Site  Site.hs
root@AR:/usr/local/da-x-hakyll-site# cd provider
root@AR:/usr/local/da-x-hakyll-site/provider# cd posts
root@AR:/usr/local/da-x-hakyll-site/provider/posts# nano test-1.md
root@AR:/usr/local/da-x-hakyll-site/provider/posts# cat test-1.md
---
excerpt: abc
title: 测试1
published: 2016-12-17 15:12:00
author: brite fisherman
---

这是测试1.

看看如何?
root@AR:/usr/local/da-x-hakyll-site/provider/posts# cd ../..
root@AR:/usr/local/da-x-hakyll-site# .stack-work/dist/i386-linux/Cabal-1.22.5.0/build/site/site rebuild

演示网站:http://dhs.bright.biz.st
项目地址:https://github.com/da-x/hakyll-site