Pages

Wednesday, 8 January 2014

在linux vps上搭建基于nodejs 的静态博客程序-gabby

npm install -g gabby
gabby init gabby-site (在当前目录下,会生成gabby-site目录)
cd gabby-site

as3:~/gabby-site# ls
content  generated  public  scripts  styles  templates
as3:~/gabby-site# cd generated
as3:~/gabby-site/generated# ls
images  index.html  screen.css 
as3:~/gabby-site/generated#
可见~/gabby-site/generated/就是静态网站的根目录。
as3:~/gabby-site/generated# nohup Rwebserver 35190 > /dev/null &
访问http://as3.brite.biz:35190/,就可看到网站效果。

发贴方法:
as3:~/gabby-site/generated# cd ..
as3:~/gabby-site# ls
content  generated  public  scripts  styles  templates
as3:~/gabby-site# cd content
as3:~/gabby-site/content# ls
index.md 
as3:~/gabby-site/content#
按index.md的内容格式,新建帖子test1.md,格式如下:
Title: test1(测试1)
Template: index.html

这是测试1.

然后,
as3:~/gabby-site/content# cd ..
as3:~/gabby-site# gabby build ~/gabby-site/ (这个就是更新静态网站的命令)

演示站点:http://as3.brite.biz:35190/
不过首页并不自动显示已发表的文章的超链,可这样处理:(编辑源帖所在目录里的index文件)
nano ~/gabby-site/content/index.md
在<h2 class="center">A beautifully simple static site generator for node.js</h2>行的上面一行加入:
<p><a href=/test1.html>测试1</a></p>
<p><a href=/test2.html>测试2</a></p>
<p><a href=/test3.html>测试3</a></p>
<p><a href=/fengyuwuzu.html>风雨无阻</a></p>
<p><a href=/chinese-economy.html>中国经济</a></p>
然后运行gabby build ~/gabby-site/,更新一下静态网站。
项目地址:https://github.com/alexmingoia/gabby