Total Pageviews

Monday, 18 July 2016

基于go的静态博客程序-ink

首先安装go环境。下载相应的go包,解压(我是解压在/usr/local/下。)然后设置/usr/local/go/bin/到环境变量中:
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile && source /etc/profile
这样go环境就装好了。

cd /usr/local/go/
go get github.com/InkProject/ink
安装完成后,可执行文件ink就会出现在/usr/local/go/bin/里面


cd /usr/local/go/src/github.com/InkProject/ink/
root@AR:/usr/local/go/src/github.com/InkProject/ink# cd template
root@AR:/usr/local/go/src/github.com/InkProject/ink/template# ls
config.yml  README.md  source  theme
root@AR:/usr/local/go/src/github.com/InkProject/ink/template# nano config.yml
root@AR:/usr/local/go/src/github.com/InkProject/ink/template# ink build
root@AR:/usr/local/go/src/github.com/InkProject/ink/template# ls
config.yml  public  README.md  source  theme
(生成了public目录)
root@AR:/usr/local/go/src/github.com/InkProject/ink/template# cd public
root@AR:/usr/local/go/src/github.com/InkProject/ink/template/public# ls
about.me.html        ink-blog-tool-en.html    tag.html favicon.png         ink-blog-tool.html   archive.html       images         page2.html        atom.xml       index.html         robots.txt
bundle           index.json         tag
(/usr/local/go/src/github.com/InkProject/ink/template/public/里面有index.html,可见/usr/local/go/src/github.com/InkProject/ink/template/public/就是静态网站的根目录,你可绑定域名到该目录)

新建帖子:
root@AR:/usr/local/go/src/github.com/InkProject/ink/template/public# cd ..
root@AR:/usr/local/go/src/github.com/InkProject/ink/template# cd source
root@AR:/usr/local/go/src/github.com/InkProject/ink/template/source# ls
about.me.html  ink-blog-tool-en.md  images  ink-blog-tool.md
root@AR:/usr/local/go/src/github.com/InkProject/ink/template/source# nano test-1.md
(按ink-blog-tool.md的文件格式,新建 test-1.md如下:
title: "测试1"
date: 2016-07-18 16:38:00 +0800
author: me
cover: "-/images/example.png"
tags:
    - testing
    - misc
preview: 这是测试

---

这是测试1.看看如何呢? )

root@AR:/usr/local/go/src/github.com/InkProject/ink/template/source# cd ..
root@AR:/usr/local/go/src/github.com/InkProject/ink/template# ink build
(ink build就是生成静态网站的命令)

演示站点:http://surmount.biz.st:4321/, http://ink.smt.biz.st/
项目地址:https://github.com/InkProject/ink
https://github.com/InkProject/ink/tree/develop/template 

中国人其实很聪明,这个程序很不错。有分页功能。不像之前那个鬼佬的静态博客程序gatsby居然没有分页功能。