Ubuntu 14.04 LTS安装Pelican elegant主题

2014-05-02
#Unix #Blog

一. 安装软件及环境准备:

1.软件安装:

$ sudo apt-get install python-pip
$ sudo apt-get install python-virtualenv
$ virtualenv ~/virtualenvs/pelican
$ cd ~/virtualenvs/pelican
$ . bin/activate
$ pip install -e git://github.com/getpelican/pelican#egg=pelican
$ pip install Markdown
$ mkdir blog
$ cd blog
$ pelican-quikstart
blog/
|--content #存储所写的blog文件目录,
|   └──(blog pages) #博客文件,如*.md后缀的文件
|--output #执行make publish之后,会将博客文件转换成相应的html文件及相应的存储目录
|   └──.git #执行git init之后,产生的远程仓库目录
|   └──author #作者目录,存放pelicanconf.py中指定的Author文件
|   └──category #分类目录,默认目录文件为misc,在编辑器中指定
|   └──feeds #目录,pelicanconf.py中FEED_RSS指定的XML文件
|   └──pages #目录,pelicanconf.py中ARTICLE_URL指定格式分类文件
|   └──tag #目录,存放编辑器开头所指定的Tag
|   └──theme #目录,存放博客模板文件
|   └──archives.html,authors.html,categories.html,index.html, tags.html
|——pelican-plugins #目录,pelican插件
|——develop_server.sh #pelican简易web服务器操作文件
|——fabfile.py # 与make类似,可用fab publish, fab server命令
|——Makefile #make 命令文件
|——pelicanconf.py #主要的pelican配置文件
|——publishconf.py #发布配置文件,可有可无

2.文章模板如下:

Title: Ubuntu14.04LTS安装Pelican elegant主题
Date: 2014-05-03
Category: Ubuntu
Tags: Ubuntu,Theme

This is my first page.

3. 编译page

$ make html  #出现错误,修改pelicanconf.py
$ make publish
$ make serve #查看 http://localhost:8000

4.创建一个页面

这里以创建 About页面为例,在content目录创建pages目录

$ mkdir content/pages

然后创建About.md并填入下面内容

Title: About Me
Date: 2013-05-03

About me content

执行 make html 生成html, 然后打http://localhost:8000查看效果.

5.推送到github网页:

$ cd output
$ git init
$ git add .
$ git remote add origin  https://github.com/xiaoledeng/xiaoledeng.github.io
$ git pull origin master
$ git add .
$ git commit -m "your message"
$ git push --force origin master

二. 安装pelican-elegant主题:

复制 pelican-elegant-1.3文件夹到pelican目录下

在pelicanconf.py中添加

THEME = 'pelican-elegant-1.3'

然后重新make publish即可

三. 谷歌分析:

去Google Analytics申请账号,记下跟踪ID。

在pelicanconf.py添加

GOOGLE_ANALYTICS = '跟踪ID' 

Reference:

  1. http://blog.csdn.net/zwjlpeng/article/details/16918289
  2. http://blog.csdn.net/zwjlpeng/article/details/18010345
  3. http://www.dongxf.com/3_Build_Personal_Blog_With_Pelican_And_GitHub_Pages.html
  4. http://akenzc.com/how-to-build-a-blog-with-pelican.html