Total Pageviews

Sunday, 21 August 2016

搭建基于hakyll的静态博客程序rohanjain.in

先安装ghc和hakyll.
cd /usr/local
git clone https://github.com/crodjer/rohanjain.in rohanjain.in-site
cd rohanjain.in-site

root@AR:/usr/local/rohanjain.in-site# ls
_cache favicon.ico  perpam.cabal  robots.txt  site.hs     static
CNAME LICENSE      posts   scripts     templates
drafts pages     README.mkd    Setup.hs    stack.yaml

root@AR:/usr/local/rohanjain.in-site# ghc --make site.hs
root@AR:/usr/local/rohanjain.in-site# ls
_cache favicon.ico  perpam.cabal  robots.txt  site site.hs     static
CNAME LICENSE      posts   scripts     site.o templates
drafts pages     README.mkd    Setup.hs    site.hi stack.yaml
(生成了可执行文件site)
root@AR:/usr/local/rohanjain.in-site# ./site build 
root@AR:/usr/local/rohanjain.in-site# ls
_cache favicon.ico  perpam.cabal  robots.txt  site site.hs     static
CNAME LICENSE      posts   scripts     _site site.o     templates
drafts pages     README.mkd    Setup.hs    site.hi stack.yaml
(生成了_site目录)
root@AR:/usr/local/rohanjain.in-site# cd _site
root@AR:/usr/local/rohanjain.in-site/_site# ls
about
archive
bash
bell
chinese-economy
CNAME
configure-ssh-to-handle-proxies-and-tunnels-seamlessly
emacs-flymake-with-virtualenvs-in-python-mode
favicon.ico
feed.xml
hakyll-clean-urls
hakyll-sitemap
hakyll-years
index.html
infi-mail
robots.txt
route-to
sitemap.xml
sky
static
tags
telescope
test-1
test-2
uchinese-economy
vair-disaster
vnc
ws-test
yet-another-vim-productivity-post-server-client
root@AR:/usr/local/rohanjain.in-site/_site#
(可见/usr/local/rohanjain.in-site/_site/就是静态网站的根目录)

新建源贴:
root@AR:/usr/local/rohanjain.in-site/_site# cd ..
root@AR:/usr/local/rohanjain.in-site# ls
_cache favicon.ico  perpam.cabal  robots.txt  site site.hs     static
CNAME LICENSE      posts   scripts     _site site.o     templates
drafts pages     README.mkd    Setup.hs    site.hi stack.yaml
root@AR:/usr/local/rohanjain.in-site# cd posts
root@AR:/usr/local/rohanjain.in-site/posts# ls
2011  2012  2014  2015 2016
root@AR:/usr/local/rohanjain.in-site/posts# cd 2016
root@AR:/usr/local/rohanjain.in-site/posts/2016# ls
infi-mail.mkd  telescope.mkd     
sky.mkd            
root@AR:/usr/local/rohanjain.in-site/posts/2016# nano test-1.mkd 
root@AR:/usr/local/rohanjain.in-site/posts/2016# cat test-1.mkd 
---
title: 测试1
date: 2016-08-21
tags: misc1, misc2, misc3
---

这是测试1.
root@AR:/usr/local/rohanjain.in-site/posts/2016# 
root@AR:/usr/local/rohanjain.in-site/posts/2016# ls
infi-mail.mkd  telescope.mkd test-2.mkd            vair-disaster.mkd    
sky.mkd        test-1.mkd    uchinese-economy.mkd
(源贴的排列顺序从上倒下,按字母顺序,从a到z;按数字,从小到大排列。越排在后面的帖子,发表后,越显示在页面的上方。所以我在发表test-1.mkd 和test-2.mkd后,新建帖子chinese-economy.mkd,为了使chinese-economy.mkd发表后,显示在test-2.mkd所对应的帖子的上方,所以把chinese-economy.mkd重命名为uchinese-economy.mkd,因为字母u排在字母t之后)
root@AR:/usr/local/rohanjain.in-site/posts/2016# cd /usr/local/rohanjain.in-site/
root@AR:/usr/local/rohanjain.in-site# ./site build

演示网站:http://rhj.smt.biz.st
项目地址:https://github.com/crodjer/rohanjain.in