发现一个“老古董”。
前言
我也喜欢很酷炫的博客,但 1.没机子,2.一些好看的博客要么配置复杂,要么运行有些卡。所以退一步想找一种极简风的博客。说实话,我喜欢极简很大的原因是极繁不可得,当然极简自带一股”高级感“,也确实是不错的选择。
我问“D老师”:“有什么可以把写完的 .md 转成 html 的轻量的工具?”它推荐的其中一项是”pelican“,网上有资料但不多,而且时间比较早,我猜这是 2010年以前的工具。尝试了一下,迎面而来的复古感意外地戳我,像是在看韦斯安德森的电影。下面介绍一下用法。
使用
官方文档:https://docs.getpelican.com/en/latest/quickstart.html
我是 win11 系统。
D:\blog> mkdir pelican-demo
D:\blog> cd pelican-demo
D:\blog\pelican-demo> python -m venv .venv
D:\blog\pelican-demo> .venv\Scripts\activate
(.venv) D:\blog\pelican-demo> pip install "pelican[markdown]"
...
# [] 中是默认值,不想改就直接回车
# (Y/n) (y/N) 大写的是默认值
(.venv) D:\blog\pelican-demo> pelican-quickstart
Welcome to pelican-quickstart v4.11.0.post0.
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? doro's blog # <= 我填了这里
> Who will be the author of this web site? miku # <= 填了这里
> What will be the default language of this web site? [Chinese (Simplified)]
> Do you want to specify a URL prefix? e.g., https://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/Rome] Asia/Shanghai # <= 填了这里
> Do you want to generate a tasks.py/Makefile to automate generation and publishing? (Y/n)
> Do you want to upload your website using FTP? (y/N)
> Do you want to upload your website using SSH? (y/N)
> Do you want to upload your website using Dropbox? (y/N)
> Do you want to upload your website using S3? (y/N)
> Do you want to upload your website using Rackspace Cloud Files? (y/N)
> Do you want to upload your website using GitHub Pages? (y/N)
Done. Your new project is available at D:\learn\python\blog\pelican-demo
结构
pelican-demo/
├── .venv/
├── content/
│ └── 这里写博客
├── output/
│ └── .md 转 html 输出结果,用这个部署
├── Makefile
├── pelicanconf.py # 配置文件
├── publishconf.py
└── tasks.py
官网的例子
# 写博客
# 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.
# .md -> html 的命令
(.venv) D:\blog\pelican-demo> pelican content
[21:58:04] WARNING Docutils has no localization for 'chinese (simplified)'. Using 'en' instead.
Done: Processed 1 article, 0 drafts, 0 hidden articles, 0 pages, 0 hidden pages and 0 draft pages in 0.17 seconds.
# pelicanconf.py
# 改回 en 就没有 warning 了
# DEFAULT_LANG = 'Chinese (Simplified)' => DEFAULT_LANG = 'en'
(.venv) D:\blog\pelican-demo>pelican content
Done: Processed 1 article, 0 drafts, 0 hidden articles, 0 pages, 0 hidden pages and 0 draft pages in 0.09 seconds.
(.venv) D:blog\pelican-demo> pelican --listen
Serving site at: http://127.0.0.1:8000 - Tap CTRL-C to stop
其他操作
favicon
# content/ 下新建 extra/,把 favicon.ico 放里面
# pelicanconf.py 末尾添加
STATIC_PATHS = (
'extra',
)
EXTRA_PATH_METADATA = {
'extra/favicon.ico': {'path': 'favicon.ico'},
}
链接
# pelicanconf.py
LINKS = (
...
("Doro美术馆", "https://doro.x00.net"),
)
SOCIAL = (
("nodeloc", "https://www.nodeloc.com"),
)
博客也可以写在文件夹中
# content/ 下新建 fit/2026-06.md
Title: 六月的锻炼
Summary: 跑了几次
Authors: miku
Date: 2026-06-20 22:00
Modified: 2026-06-20 22:30
Category: fit
Tags: 2026 run
## 锻炼流水帐
- 06-06 晚跑了3km
- 06-13 晚跑了5km
- 06-20 晚跑了5km
默认是拼音 http://127.0.0.1:8000/liu-yue-de-duan-lian.html
文章顶部添加 Slug: run-2026-06 后是 http://127.0.0.1:8000/run-2026-06.html
主题
https://github.com/getpelican/pelican-themes- 根目录新建
pelican-themes/,把喜欢的主题下到这里 - 比如我下了 mnmlist,publishconf.py 中添加一句
THEME = "pelican-themes/mnmlist"
图片
# 1.
# 默认主题,content/ 下新建 images/

# 其他主题,如 mnmlist
# pelican-demo/pelican-themes/mnmlist/static/ 下新建 images/
# 2. publishconf.py
STATIC_PATHS = (
'extra',
'images', # 添加这行
)
总结
pelican-quickstart
pelican content
pelican --listen
部署
- 我只是记录一些日常
- 去年年底机缘巧合来到 NL,才知道 cloudflare
- 可以把 output/ 中的内容部署到 cf 的 pages
6
3
3 条回复
排序