梦里依稀的小湖 有些事,记下来是不错的选择...

用pelican搭建自己的blog

Pelican Static Site Generator, Powered by Python:Pelican是python语言写的静态网站生成器。

首先,用virtualenv创建一个env

`mkdir blog`
`cd blog`
`virtualenv env`
`source env/bin/activate  #激活环境`

接着,使用pip安装pelican和markdown

`pip install pelican`
`pip install markdown`

其次,创建pelican目录结构

`pelican-quickstart`

根据提示进行设置

`Where do you want to create your new web site? [.]`
`What will be the title of this web site? 梦里依稀的小湖`
`Who will be the author of this web site? Andrew`
`What will be the default language of this web site? [en] zh`
`Do you want to specify a URL prefix? e.g., http://example.com   (Y/n)`
`What is your URL prefix? (see above example; no trailing slash) dreaminlake.com`
`Do you want to enable article pagination? (Y/n)`
`How many articles per page do you want? [10]`
`What is your time zone? [Europe/Paris] Asia/Shanghai`
`Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n)`
`Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n)`
`Do you want to upload your website using FTP? (y/N) n`
`Do you want to upload your website using SSH? (y/N) n`
`Do you want to upload your website using Dropbox? (y/N) n`
`Do you want to upload your website using S3? (y/N) n`
`Do you want to upload your website using Rackspace Cloud Files? (y/N) n`
`Do you want to upload your website using GitHub Pages? (y/N)`
`Done.`

文件结构如下:

`blog/`
`├── content              # 写的文章放这里`
`├── output               # 生成的输出文件(发布的内容)`
`├── develop_server.sh    
`├── Makefile             # 方便管理博客的Makefile`
`├── pelicanconf.py       # 主配置文件`
`└── publishconf.py`

然后,编写文章测试下效果

Date: 2016-02-28`
`Title: 测试`
`Tags: 测试`
`Slug: test`

# `pelican`

`Pelican Static Site Generator, Powered by PythonPelican是python语言写的静态网站生成器

在content目录下创建一个名为:test.md的markdown文件,把上面的那些内容放进去,用来测试效果。

接着,本地测试

在blog目录下执行

pelican content # 根据content中的内容,生成静态网站到output目下

在output目录下执行

python -m pelican.server

以上两个命令执行完,没有报错的话就用浏览器打开:127.0.0.1:8000,效果如下:

输入:ctrl + c 停止服务