先按此文http://briteming.blogspot.com/2016/07/hakyll.html,搭建stack,ghc,hakyll.
cd /usr/local
git clone https://github.com/maseek/maseek-codes maseek.codes
cd maseek.codes
cd src
nano site.hs
(把以下这行:
import System.Locale (defaultTimeLocale)
改为:
import Data.Time.Format (formatTime, defaultTimeLocale)
删掉最下面的2行:
pandocCompile :: Item String -> Compiler (Item String)
pandocCompile item = return $ writePandoc $ readPandoc item
cd /usr/local
git clone https://github.com/maseek/maseek-codes maseek.codes
cd maseek.codes
cd src
nano site.hs
(把以下这行:
import System.Locale (defaultTimeLocale)
改为:
import Data.Time.Format (formatTime, defaultTimeLocale)
删掉最下面的2行:
pandocCompile :: Item String -> Compiler (Item String)
pandocCompile item = return $ writePandoc $ readPandoc item
)
ghc --make site.hs
(此步会在当前目录下,生成可执行文件site)
root@AR:/usr/local/maseek.codes/src# ls
404.html css index.html quarter-brain site.hs
4913 etc js robots.txt site.o
about.rst favicon.ico posts site templates
_cache fonts projects.html site.hi
contact.markdown images publish.sh
root@AR:/usr/local/maseek.codes/src# ./site rebuild (这就是生成静态网站的根目录的命令)
root@AR:/usr/local/maseek.codes/src# ls
404.html css index.html quarter-brain site.hs
4913 etc js robots.txt site.o
about.rst favicon.ico posts site templates
_cache fonts projects.html _site
contact.markdown images publish.sh site.hi
(生成了_site目录)
root@AR:/usr/local/maseek.codes/src# cd _site
root@AR:/usr/local/maseek.codes/src/_site# ls
404.html contact.html feed.xml js quarter-brain
about.html css images posts robots.txt
archive.html favicon.ico index.html projects
root@AR:/usr/local/maseek.codes/src/_site#
(可见/usr/local/maseek.codes/src/_site就是静态网站的根目录)
新建源帖:
root@AR:/usr/local/maseek.codes/src/_site# cd ../posts
root@AR:/usr/local/maseek.codes/src/posts# nano test-1.markdown
root@AR:/usr/local/maseek.codes/src/posts# cat test-1.markdown
---
title: 测试1
tags: misc1, misc2, misc3
published: 2016-11-15
---
这是测试1.
看看如何?
root@AR:/usr/local/maseek.codes/src/posts# cd ..
root@AR:/usr/local/maseek.codes/src# ./site rebuild
演示网站:http://mc.bright.biz.st
项目地址:https://github.com/maseek/maseek-codes
上面搭建这个博客程序看似简单,但之前我搭建时,由于未删掉site.hs文件的最下面的2行,结果就是搭建不成功。