Total Pageviews

Tuesday 15 October 2013

在linux vps上搭建基于python 的静态博客生成器-Lilac

# pip install lilac
(或者这样装也行:
# git clone git://github.com/hit9/lilac.git
# cd lilac
# pip install . -I
不要运行python setup.py install)
from https://lilac-zh.readthedocs.org/en/latest/install.html

首先需要新建一个空目录,然后进入它,执行 lilac deploy :
$ mkdir lilac-blog
$ cd lilac-blog
$ lilac deploy

ls下看看发生了什么:
$ ls
classic  config.toml  Makefile  src
这一步lilac生成了一份配置文件 config.toml, 一份样例文章 src/post/sample.md , 和默认主题 classic 。
而且,同时生成了一个 Makefile 来帮助你管理博客。

下一步就是来配置下博客了。
配置博客
配置文件相当简单,让我们大致看下config.toml:
root_path = ""

[blog]
name = "Make Difference"
description = "Here goes your blog's description"
url = "http://your-blog.org"
theme = "classic"

[author]
name = "me"
email = "me@some.com"

[disqus]
shortname = "your-disqus-short-name"

[theme.vars]
github = "your-github-username"
这份配置文件是 TOML 语言的, 但是我们不必去追究TOML到底的语法是怎么样的。
我们需要编辑这份自动生成的样例配置。
注意: 除非你的博客将要部署到子目录下,你一般不必修改’root_path’这一项.

新建一篇文章, 只要在目录 src/post下新建这个文件:
$ vi src/post/Hello-World.md
这里是一个示例文章:
title = "Hello World!"
datetime = "2013-06-05 17:30"
---
Hello World...

更多参考文章语法- https://lilac-zh.readthedocs.org/en/latest/post.html#post

as3:~/lilac-blog/src/post# cd ~/lilac-blog/
as3:~/lilac-blog# lilac build这是生成静态网站的命令.每次建立新帖后,都要运行该命令,重新生成一次静态网站
from https://lilac-zh.readthedocs.org/en/latest/commands.html#command-serve)
as3:~/lilac-blog# ls
404.html    archives.html  feed.atom   less      page  src  tags.html
about.html  config.toml    index.html  Makefile  post  tag
as3:~/lilac-blog# (这个~/lilac-blog/目录就是静态网站的根目录。你可绑定一个域名到该目录)
demo site: http://as3.brite.biz:2277/ ,http://lilac.brite.biz/

你可以新起一个shell会话来启动lilac的预览服务器:
# cd /root/lilac-blog/
as3:~/lilac-blog# nohup make serve > /dev/null &
这个命令会在当前目录开启一个web服务器,并且会监视博文源文件的变动.
然后访问 http://localhost:8888 来预览博客。demo site: http://as3.brite.biz:8888/
或者:
开启一个简单的Web服务器:
# nohup lilac serve > /dev/null &
可以指明端口(默认端口8888):
# nohup lilac serve 9090 > /dev/null &
demo site: http://as3.brite.biz:9090/




参考https://lilac-zh.readthedocs.org/en/latest/
项目地址: http://github.com/hit9/lilac