先按此文http://briteming.blogspot.com/2016/07/hakyll.html安装hakyll.
cd /usr/local
git clone https://github.com/celadevra/hakyll-site celadevra-hakyll-site
cd celadevra-hakyll-site
cd /usr/local
git clone https://github.com/celadevra/hakyll-site celadevra-hakyll-site
cd celadevra-hakyll-site
root@AR:/usr/local/celadevra-hakyll-site# ls
about.page LICENSE
bib logic-behind-city-renewal.page
blog make-this-not-true-translation.page
but-i-didnt.page money.page
_cache movie-games.page
changelog.page multi-factor-decision-making.page
csl newsletter.page
css newsletters
dev.hs non-academia-research.page
Dockerfile README.md
docs read-me.page
expoundite.cabal retouch.sh
favicon.ico ruby
fonts Setup.hs
gdal.page
gentrification.page
googleeb2ce2a69786566d.html
gpg-intro.page site.hs
history-of-childrearing.page
images story-of-the-undead.page
index.page templates
js unfinished-games.page
keybase.txt wikipedia.page
leaflet.page
root@AR:/usr/local/celadevra-hakyll-site# ghc --make site.hs
(此命令会在当前目录下,生成可执行文件site)
root@AR:/usr/local/celadevra-hakyll-site# ls
about.page LICENSE
bib logic-behind-city-renewal.page
blog make-this-not-true-translation.page
but-i-didnt.page money.page
_cache movie-games.page
changelog.page multi-factor-decision-making.page
csl newsletter.page
css newsletters
dev.hs non-academia-research.page
Dockerfile README.md
docs read-me.page
expoundite.cabal retouch.sh
favicon.ico ruby
fonts Setup.hs
gdal.page site
gentrification.page
googleeb2ce2a69786566d.html site.hi
gpg-intro.page site.hs
history-of-childrearing.page site.o
images story-of-the-undead.page
index.page templates
js unfinished-games.page
keybase.txt wikipedia.page
leaflet.page
root@AR:/usr/local/celadevra-hakyll-site# ./site build
(此命令会在当前目录下,生成静态网站的根目录:_site)
root@AR:/usr/local/celadevra-hakyll-site# ls
about.page LICENSE
bib logic-behind-city-renewal.page
blog make-this-not-true-translation.page
but-i-didnt.page money.page
_cache movie-games.page
changelog.page multi-factor-decision-making.page
csl newsletter.page
css newsletters
dev.hs non-academia-research.page
Dockerfile README.md
docs read-me.page
expoundite.cabal retouch.sh
favicon.ico ruby
fonts Setup.hs
gdal.page site
gentrification.page _site
googleeb2ce2a69786566d.html site.hi
gpg-intro.page site.hs
history-of-childrearing.page site.o
images story-of-the-undead.page
index.page templates
js unfinished-games.page
keybase.txt wikipedia.page
leaflet.page
root@AR:/usr/local/celadevra-hakyll-site# cd _site
root@AR:/usr/local/celadevra-hakyll-site/_site# ls
about history-of-childrearing newsletter
blog images newsletters
but-i-didnt index non-academia-research
changelog js read-me
css keybase.txt rss.xml
docs leaflet ruby
favicon.ico logic-behind-city-renewal story-of-the-undead
fonts make-this-not-true-translation tags
gdal money unfinished-games
gentrification movie-games wikipedia
gpg-intro multi-factor-decision-making
root@AR:/usr/local/celadevra-hakyll-site/_site#
(/usr/local/celadevra-hakyll-site/_site/里面有index文件。其实index就是index.html文件,可见/usr/local/celadevra-hakyll-site/_site/就是静态网站的根目录,你可绑定域名到该目录)
新建源贴:
root@AR:/usr/local/celadevra-hakyll-site/_site# cd ..
root@AR:/usr/local/celadevra-hakyll-site# cd blog
root@AR:/usr/local/celadevra-hakyll-site/blog# nano test-1.md
root@AR:/usr/local/celadevra-hakyll-site/blog# cat test-1.md
---
title: 测试1
date: 2016-10-04
...
这是测试1.
root@AR:/usr/local/celadevra-hakyll-site/blog# cd ..
root@AR:/usr/local/celadevra-hakyll-site# ./site build
演示网站:http://cld.bright.biz.st/
第一次访问http://cld.bright.biz.st/,显示的内容是一个列表,每次新建源贴并更新网站后,都要在_site目录里新建文件index.html,其内容为
第一次访问http://cld.bright.biz.st/,显示的内容是一个列表,每次新建源贴并更新网站后,都要在_site目录里新建文件index.html,其内容为
<meta http-equiv=refresh content="0;url=/blog/index">
我的webserver为apache2,编辑/etc/apache2/sites-available/default文件(添加虚拟主机)如下,在/etc/apache2/sites-available/default文件的最下方加上:
<VirtualHost *:80>
DocumentRoot /usr/local/celadevra-hakyll-site/_site
<Directory /usr/local/celadevra-hakyll-site/_site>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerName cld.bright.biz.st
</VirtualHost>
然后重启apache2即可:
/etc/init.d/apache2 restart
注意:上面的_site的后面不要加上斜杠!这个虚拟主机的情形不能加上斜杠,其他的虚拟主机可以加,但为了统一,建议都不要加上斜杠。
项目地址:https://github.com/celadevra/hakyll-site
本帖的方法比http://briteming.blogspot.com/2016/08/dockerhakyll.html所讲的方法简单。
http://cld.bright.biz.st/docs/
本帖的方法比http://briteming.blogspot.com/2016/08/dockerhakyll.html所讲的方法简单。
http://cld.bright.biz.st/docs/