Total Pageviews

Thursday 6 October 2016

搭建基于nodejs的静态博客程序ghost-render(这是我所搭建的最漂亮的静态博客)

npm install -g ghost-render
ghost-render --init > ghost-render-settings.json (初始化设置文件,此命令会在当前目录下生成ghost-render-settings.json文件.修改此文件,把url的值改为http://yourdomain.com ,
把name的值改为你的名字,把website的值改为http://yourdomain.com/author/foo )
git clone https://github.com/TryGhost/Casper casper (克隆一个ghost的主题。主题就是“皮肤”)
创建一个源贴内容:
mkdir -p ghost-render-blog/2016/10/06/

echo "你好,世界" > ghost-render-blog/2016/10/06/hello-world.md

然后运行生成静态网站的根目录的命令:
ghost-render --input ghost-render-blog --settings ghost-render-settings.json --theme casper --output /usr/local/ghost-render-blog-output (此命令会在/usr/local/下,生成目录ghost-render-blog-output.为方便起见,可把该行命令保存为ghost-render.sh)

root@AR:~# cd /usr/local/ghost-render-blog-output
root@AR:/usr/local/ghost-render-blog-output# ls
2016  assets  author  index.html  page rss  tag
root@AR:/usr/local/ghost-render-blog-output#
(可见/usr/local/ghost-render-blog-output/就是静态网站的根目录。你可绑定你的域名到该目录)

上面创建源贴的方法比较“粗燥”,我们可以用如下办法来创建源贴:

root@AR:/usr/local/ghost-render-blog-output# cd ~
root@AR:~# ls
ghost-render-blog    
ghost-render-settings.json
root@AR:~# cd ghost-render-blog
root@AR:~/ghost-render-blog# ls
2016
root@AR:~/ghost-render-blog# cd 2016
root@AR:~/ghost-render-blog/2016# ls
10
root@AR:~/ghost-render-blog/2016# cd 10
root@AR:~/ghost-render-blog/2016/10# ls
06
root@AR:~/ghost-render-blog/2016/10# cd 06
root@AR:~/ghost-render-blog/2016/10/06# nano test-1.md
root@AR:~/ghost-render-blog/2016/10/06# cat test-1.md
---
title: 测试1
published_at: 2016-10-06 00:47:04
tags: misc
---

这是测试1.
root@AR:~/ghost-render-blog/2016/10/06# cd ~
root@AR:~# sh ghost-render.sh

演示网站:http://gr.bright.biz.st
项目地址:https://github.com/mixu/ghost-render,
https://github.com/TryGhost/Casper

相关帖子:http://briteming.blogspot.com/2014/05/linux-vpspython-peanut.html,这个peanut博客程序用的也是ghost的皮肤。