Title: 使用Pelican搭建博客系统

Date: 2016-07-30 22:20

Modified: 2016-07-30 22:20

Tags: python, pelican

Slug:  

Authors: Peng Ruifang

Summary: 本文介绍了Pelican的特性,搭建出一个可运行的独立博客系统。

Status: draft





# 目录

---

[TOC]

http://pelican-docs-zh-cn.readthedocs.io/en/latest/


---

## CentOS6 install Python2.7

```shell

wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz

tar -zxvf Python*.tgz 

cd Python*

./configure  

make all             

make install  

make clean  

make distclean

```


```shell

mv /usr/bin/python /usr/bin/python2.6.6  

ln -s /usr/local/bin/python2.7 /usr/bin/python


vi /usr/bin/yum  


#!/usr/bin/python

改成

#!/usr/bin/python2.6

```

## Install Pip

```

wget https://bootstrap.pypa.io/get-pip.py

sudo python get-pip.py 

```

### ubuntu install pip


Ubuntu下安装pip的方法

 

安装pip的方法:

``` 

sudo apt-get install python-pip python-dev build-essential 

sudo pip install --upgrade pip 

sudo pip install --upgrade virtualenv 


```

```

For older versions of Ubuntu

Install Easy Install

$ sudo apt-get install python-setuptools python-dev build-essential 

Install pip

$ sudo easy_install pip 

Install virtualenv

$ sudo pip install --upgrade virtualenv 

```

---

## Install pelican markdown


```

$ sudo pip install pelican markdown

```


---

## Init pelican env

```

mkdir -p /home/wwwroot/init.wang

cd  /home/wwwroot/init.wang 

$ sudo pelican-quickstart

ok@ok-pc:~/pelican$ sudo pelican-quickstart

Welcome to pelican-quickstart v3.6.3.


This script will help you create a new Pelican-based website.


Please answer the following questions so this script can generate the files

needed by Pelican.


    

> 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? PengRuifang

> 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) n

> 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. Your new project is available at /home/ok/pelican


```


Then,the files like below:

```

ok@ok-pc:~/pelican$ tree

.

├── content

├── develop_server.sh

├── fabfile.py

├── get-pip.py

├── Makefile

├── output

├── pelicanconf.py

└── publishconf.py


2 directories, 6 files

```


---

##  First pelican page

```

cd ./content

vim test1.md


Title: My super title

Date: 2010-12-03 10:20

Modified: 2010-12-05 19:30

Category: Python

Tags: pelican, publishing

Slug: my-super-post

Authors: Alexis Metaireau, Conan Doyle

Summary: Short version for index and feeds


This is the content of my super blog post.

```


```

cd ../content

pelican ./content

cd ./output

python -m SimpleHTTPServer


firefox 127.0.0.1:8000

```

## Upload the pages to Github

```

ssh-keygen -t rsa  -b 4096 -C "okeyear@163.com"

cd ~/.ssh

cat id_rsa.pub  #内容复制到github的ssh keys里面

然后本机

ssh -T git@github.com




```

github新建一项目,必须以自己用户名开始,并且以.github.com 或.github.io结尾

比如:okeyear.github.com

```

cd ./output

git init

git add .

git commit -m "pelican blog test"

# git remote rm origin

git remote add origin git@github.com:okeyear/okeyear.github.com.git

git push -u origin master




```


### pelican theme


```

git clone https://github.com/getpelican/pelican-themes.git

从里面拷贝一份你选中的主题到项目根目录的 themes 目录下

然后在 pelicanconf.py 和 publishconf.py 里通过下面代码指定博客主题:

THEME = "themes/foundation-default-colours"


FOUNDATION_FRONT_PAGE_FULL_ARTICLES = False

FOUNDATION_ALTERNATE_FONTS = False

FOUNDATION_TAGS_IN_MOBILE_SIDEBAR = False

FOUNDATION_NEW_ANALYTICS = False

FOUNDATION_ANALYTICS_DOMAIN = ''

FOUNDATION_FOOTER_TEXT = 'Powered by <a href="http://getpelican.com">Pelican</a> and <a href="http://foundation.zurb.com/">Zurb Foundation</a>. Theme by <a href="http://hamaluik.com">Kenton Hamaluik</a>.'

FOUNDATION_PYGMENT_THEME = 'monokai'

```


### 域名解析


添加一CNAME文件,无后缀名,里面写上自己的域名;


域名解析地方添加CNAME,指向okeyear.github.io


### 博客模版

```

Title: 使用Pelican搭建博客系统

Date: 2014-10-07 22:20

Modified: 2014-10-07 23:04

Tags: python, pelican

Slug: build-blog-system-by-pelican

Authors: Joey Huang

Summary: 本文介绍了Pelican的特性;选择Pelican的理由以及从头安装配置,搭建出一个可运行的独立博客系统。

Status: draft

```