天天看點

pelican github搭建部落格

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

```

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 "[email protected]"

cd ~/.ssh

cat id_rsa.pub  #内容複制到github的ssh keys裡面

然後本機

ssh -T [email protected]

github建立一項目,必須以自己使用者名開始,并且以.github.com 或.github.io結尾

比如:okeyear.github.com

git init

git add .

git commit -m "pelican blog test"

# git remote rm origin

git remote add origin [email protected]: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

### 部落格模版

Date: 2014-10-07 22:20

Modified: 2014-10-07 23:04

Slug: build-blog-system-by-pelican

Authors: Joey Huang

Summary: 本文介紹了Pelican的特性;選擇Pelican的理由以及從頭安裝配置,搭建出一個可運作的獨立部落格系統。