Total Pageviews

Tuesday 4 February 2014

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

git clone https://github.com/venthur/sg sg2
cd sg2

as3:~/sg2# ls
README  sg.py
as3:~/sg2# ./sg.py
INFO    Checking if all needed dirs and files are available.
WARNING Directory '_layouts' does not exist, creating it.
WARNING Directory '_static' does not exist, creating it.
WARNING File '_layouts/default.html' does not exist, creating it.
INFO    Copying static content.
INFO    Generating Site.
as3:~/sg2# ls
_layouts  README  sg.py  _site  _static
as3:~/sg2# mkdir content
as3:~/sg2# ls
content  _layouts  README  sg.py  _site  _static
as3:~/sg2# cd content
as3:~/sg2/content# nano index.markdown
as3:~/sg2/content# cat index.markdown
## 首页
as3:~/sg2/content# nano test1.markdown
test1.markdown的格式为:
## 测试1

这是测试1.
as3:~/sg2/content# cd ..
as3:~/sg2# ./sg.py (这个就是生成/更新静态网站的命令)
as3:~/sg2# cd _site
as3:~/sg2/_site# ls
content
as3:~/sg2/_site# cd content
as3:~/sg2/_site/content# ls
index.html  test1.html
as3:~/sg2/_site/content#
可见~/sg2/_site/content/就是静态网站的根目录。
as3:~/sg2/_site/content# ls
chinese-economy.html  fengyuwuzu.html  index.html  test1.html  test2.html
as3:~/sg2/_site/content#
不过首页并不会显示已发表的文章,可这样做:
编辑源目录中的index文件,加入
<p><a href=/test1.html>测试1</a>
<p><a href=/test2.html>测试2</a>
<p><a href=/fengyuwuzu.html>风雨无阻</a>
<p><a href=/chinese-economy.html>中国经济</a>

as3:~/sg2/_site/content# cd ~/sg2
as3:~/sg2# cd content
as3:~/sg2/content# ls
chinese-economy.markdown  index.markdown  test2.markdown
fengyuwuzu.markdown       test1.markdown
as3:~/sg2/content# cat index.markdown
## 首页

<p><a href=/test1.html>测试1</a>
<p><a href=/test2.html>测试2</a>
<p><a href=/fengyuwuzu.html>风雨无阻</a>
<p><a href=/chinese-economy.html>中国经济</a>


演示站点:HTTP://sg.briteming.yi.org
项目地址:https://github.com/venthur/sg