[实例] 自动动手制作Pelican主题

我创建的主题

第1个主题

第1个主题

使用主题

# Specify name of a built-in theme
THEME = "notmyidea"
# Specify name of a theme installed via the pelican-themes tool
THEME = "chunk"
# Specify a customized theme, via path relative to the settings file
THEME = "themes/mycustomtheme"
# Specify a customized theme, via absolute path
THEME = "~/projects/mysite/themes/mycustomtheme"

目录结构

├── static                    // 会被复制到 output/theme 文件夹
   ├── css
   └── images
└── templates
    ├── archives.html         // to display archives
    ├── period_archives.html  // to display time-period archives
    ├── article.html          // processed for each article
    ├── author.html           // processed for each author
    ├── authors.html          // must list all the authors
    ├── categories.html       // 列出所有分类目录
    ├── category.html         // processed for each category
    ├── index.html            // the index. List all the articles
    ├── page.html             // processed for each page
    ├── tag.html              // processed for each tag
    └── tags.html             // 列出所有标签, 可以是标签云

快速的方案是拷贝已有的主题进行修改

模板 和 变量

共同的变量

即在每个模板中能使用的变量, 其中在配置文件中定义的变量在所有模板中都能使用

例如: 作者 {{ AUTHOR }}

变量 描述
output_file 当前生成的文件的文件名. 例如, 当Pelican渲染主页时, output_file的值为"index.html".
articles 文章列表, 根据日期降序排序. 所有元素为Article对象, 可以访问其属性(如: title, summary, author等). 有时会被覆盖(例如在tags页中). 这时需要使用all_articles变量代替.
dates 与articles同样的列表, 但是根据日期升序排序.
tags (tag, articles)列表元组, 包含所有标签.
categories (category, articles)列表元组, 包含所有分类目录, 以及各自的文章(values)列表
pages 页面列表

每个模板页中还有特殊的变量, 很简单, 具体看官方文档

How to create themes for Pelican

pelican-themes脚本的使用

pelican-themes

不是非要使用...

我是没用上 - -


[记录] 在 Windows 下使用 Pelican + GitCafe Page 创建 Blog

在 Windows 下使用 Pelican + GitCafe Page 创建 Blog