像黑客一樣寫博客–Pelican快速搭建靜態博客

“像黑客一樣寫博客”,通過文本編輯器(Markdown編輯器)即可實現寫博客,而且是靜態的,很神奇吧,這裏的方案是Pelican.

爲啥叫 Pelican 這麼奇怪的名字
“Pelican” is an anagram for calepin, which means “notebook” in French. 😉

Pelican 是基於Python實現的開源靜態博客系統,所謂靜態博客系統就是無需數據庫,每一篇文章會事先渲染成HTML靜態文件,訪問速度非常快。所以今天給大家介紹下怎麼使用Pelican。

安裝 pelican
pip3 install pelican markdown –upgrade

創建項目

>mkdir blog  # 創建項目目錄

>cd blog # 進入項目目錄

\blog>pelican-quickstart  # 生成pelican骨架
Welcome to pelican-quickstart v3.7.1.

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.
...
Done. Your new project is available at \blog

安裝過程過,會有很多需要你輸入的配置項,如果不知道怎麼填就直接忽略或者選擇n,因爲這些配置項在後面可以自己手動再添加的。

創建完成後生成的目錄結構如下
.
├── Makefile # 管理博客
├── content/ #存放文章的源文件
├── develop_server.sh
├── fabfile.py
├── output/ #生成的靜態文件存放目錄
├── pelicanconf.py #博客配置文件
└── publishconf.py #發佈文件

第一篇makedown文章
你的文章需要保存在content目錄下,通常情況我們寫文章採用markdown語法,所以,現在我們在content目錄創建一篇文章,文章內容:

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.

生成靜態文件
pelican content

執行完成後,output 目錄會多出一些文件,markdown文件最終也會轉換成html文件放到該目錄下

選擇Apache 虛擬文件路徑,啓動你的博客網站吧: http://Youthblue.com

高級功能1:配置主題
在http://www.pelicanthemes.com/選擇自己喜歡的主題
將從pelican-themes上下載主題到本地並安裝
git clone https://github.com/getpelican/pelican-themes.git

在pelicanconf.py文件中,配置主題
THEME = “pelican-octopress-theme”

高級功能2:修改時區和默認的時間格式
TIMEZONE = ‘utc’
DATE_FORMATS = {
‘en’: ‘%a, %d %b %Y’,
‘jp’: ‘%Y-%m-%d(%a)’,
‘zh’: ‘%Y-%m-%d(%a)’,
}

AD:
http://kylinholding.com/

來源:–如果你覺得對你有幫助,麻煩請幫點一下廣告 — 就當請我吃顆糖 🍑🍒🍓,多謝。

發佈了28 篇原創文章 · 獲贊 24 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章