Total Pageviews

Monday 30 January 2017

搭建基于Haskell的静态博客程序meteficha.com

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


cd /usr/local
git clone https://github.com/meteficha/meteficha.com
cd meteficha.com

root@AR:/usr/local/meteficha.com# ghc --make site.hs
root@AR:/usr/local/meteficha.com# ./site build
root@AR:/usr/local/meteficha.com# cd _site
root@AR:/usr/local/meteficha.com/_site# ls
about.html    atom.xml    images        museum     posts
archive.html  css    index.html  museum.html  rss.xml
root@AR:/usr/local/meteficha.com/_site# 
(可见/usr/local/meteficha.com/_site目录就是静态网站的根目录.你需绑定域名到该目录)

新建源帖:
root@AR:/usr/local/meteficha.com/_site# cd ../posts
root@AR:/usr/local/meteficha.com/posts# nano 2017-01-30-test-1.md
root@AR:/usr/local/meteficha.com/posts# cat 2017-01-30-test-1.md
---
title: 测试1
---

这是测试1.

<!--more-->

看看如何?

root@AR:/usr/local/meteficha.com/posts#  cd ..
root@AR:/usr/local/meteficha.com# ./site rebuild

演示网站:http://mfc.bright.biz.st
项目地址:https://github.com/meteficha/meteficha.com

注意:帖子发表后的url是这样的:http://mfc.bright.biz.st/posts/2017-01-30-test-1,相当于是去掉了后缀“.html"。为了 达到此效果,如果你的webserver是apache,则需修改apache的配置文件如下:
 <VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /path/to/your-site-root-dir
<Directory /path/to/your-site-root-dir>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
 allow from all
 </Directory>

</VirtualHost>
需加上上述蓝色部分,重启apache即可。
(参见http://briteming.blogspot.co.uk/2014/01/linux-vpsnodejs-harp.html)

 如果你的webserver是nginx,则需修改nginx的配置文件如下:
server {
  listen 80;     
  server_name yourdomain.com;

  location / {
    root /path/to/your-site-root-dir;
    index index.html;
    if ($request_uri ~ ^/(.*)\.html$) {
       return 302 /$1;
    }
    try_files $uri $uri.html $uri/ =404;
  }
}

No comments:

Post a Comment