使用python靜態網頁生成工具pelican快速在github上部署網站部落格
簡介
Pelican用Python編寫的靜態站點生成器。亮點:
使用reStructuredText或Markdown格式直接用編輯器編寫內容
簡單的CLI工具來(重新)生成站點
易於與分散式版本控制系統和Web對接
完全靜態輸出,可在任何地方託管
使用python靜態網頁生成工具pelican快速在github上部署網站部落格
Pelican 4目前支援:
文章(例如部落格文章)和頁面(例如,“關於”,“專案”,“聯絡方式”)
評論,通過外部服務(Disqus)。如果您希望更好地控制評論,也可自託管評論是另一種選擇。
主題支援(使用Jinja2模板建立主題)
以多種語言發表文章
Atom / RSS feeds
程式碼高亮
從WordPress,Dotclear或RSS匯入
與外部工具整合:Twitter,Google Analytics等(可選)
藉助內容快取和選擇性輸出寫入,可以快速重建
為什麼叫“Pelican”這個名字?
“Pelican”是calepin的字謎,在法語中意為“筆記本”。 ;)
您可以訪問以下網址獲取原始碼:https://github.com/getpelican/pelican。更多相關庫參見https://github.com/china-testing/python-api-tesing。
安裝
pip install pelican markdown
建立專案
mkdir -p ~/projects/yoursite
cd ~/projects/yoursite
pelican-quickstart
建立文章
~/projects/yoursite/content/keyboard-review.md
Title: My First Review
Date: 2010-12-03 10:20
Category: Review
Following is a review of my favorite mechanical keyboard.
生成網站
pelican content
預覽
pelican --listen
訪問:http://localhost:8000/。
使用python靜態網頁生成工具pelican快速在github上部署網站部落格
圖片.png
github部署
比如https://github.com/china-testing/china-testing.github.io,
上傳程式碼,就可以訪問你的網站了。
#!/usr/bin/env bash
DATE=$(date +%Y%m%d)
cd /home/andrew/code/yoursite
rm -rf output/*
pelican content
cd /home/andrew/code/china-testing.github.io
git rm -rf *
cp -rf /home/andrew/code/yoursite/output/* .
git add *
git commit -m $DATE
git push
網站示例: https://china-testing.github.io/