Total Pageviews

Friday 19 August 2016

搭建基于hakyll的静态博客程序blog.clement.delafargue.name

按http://briteming.blogspot.com/2016/07/hakyll.html的蓝色字部分安装stack和ghc.
cd /usr/local
git clone https://github.com/divarvel/blog blog.clement.delafargue.name-site
cd blog.clement.delafargue.name-site

root@AR:/usr/local/blog.clement.delafargue.name-site# ls
blog.cabal       css    LICENSE   new_post.sh  _site
cabal.sandbox.config  dist   Main.hs   posts     stack.yaml
_cache       files  Makefile  Setup.hs     templates
root@AR:/usr/local/blog.clement.delafargue.name-site# 
root@AR:/usr/local/blog.clement.delafargue.name-site# rm Makefile
root@AR:/usr/local/blog.clement.delafargue.name-site# ls
blog.cabal       css    LICENSE   posts     stack.yaml
cabal.sandbox.config  dist   Main.hs   Setup.hs  templates
_cache       files  new_post.sh  

root@AR:/usr/local/blog.clement.delafargue.name-site# stack build 
(此命令会生成静态博客程序的可执行文件。会在当前目录下生成.stack-work目录.stack-work/dist/i386-linux/Cabal-1.18.1.5/build/blog/blog就是可执行文件。同时在/usr/local/blog.clement.delafargue.name-site/.stack-work/install/i386-linux/lts-2.22/7.8.4/bin/里也生成了可执行文件blog.这2个可执行文件blog是一样的。)
root@AR:/usr/local/blog.clement.delafargue.name-site# .stack-work/install/i386-linux/lts-2.22/7.8.4/bin/blog build (此即为生成/更新静态网站的命令)
root@AR:/usr/local/blog.clement.delafargue.name-site# ls
blog.cabal       css    LICENSE   posts     stack.yaml
cabal.sandbox.config  dist   Main.hs   Setup.hs  templates
_cache       files  new_post.sh  _site
(生成了_site目录)
root@AR:/usr/local/blog.clement.delafargue.name-site# cd _site
root@AR:/usr/local/blog.clement.delafargue.name-site/_site# ls
atom.xml  css  files  index.html  posts  posts.html  rss.xml  tags
root@AR:/usr/local/blog.clement.delafargue.name-site/_site#
(可见/usr/local/blog.clement.delafargue.name-site/_site/就是静态网站的根目录)

新建源贴:
root@AR:/usr/local/blog.clement.delafargue.name-site/_site# cd ..
root@AR:/usr/local/blog.clement.delafargue.name-site# cd posts
root@AR:/usr/local/blog.clement.delafargue.name-site/posts# nano 2016-08-19-1554-test-1.md
(帖子的内容格式如下:
---
title: 测试1
author: brite
tags: misc1, misc2
---

这是测试1. )
root@AR:/usr/local/blog.clement.delafargue.name-site/posts# cd ..
root@AR:/usr/local/blog.clement.delafargue.name-site# .stack-work/install/i386-linux/lts-2.22/7.8.4/bin/blog build
(或者:
root@AR:/usr/local/blog.clement.delafargue.name-site# .stack-work/dist/i386-linux/Cabal-1.18.1.5/build/blog/blog build 

感觉运行.stack-work/dist/i386-linux/Cabal-1.18.1.5/build/blog/blog build ,速度快些)

演示网站:http://bcd.smt.biz.st
项目地址:https://github.com/divarvel/blog
https://github.com/haasn/blog (某人的修改版)