主题开发
主题包目录结构
主题目录
一个可安装主题至少包含:
themes/aurora/
├─ theme.json
├─ index/index.html
├─ list/list.html
├─ show/show.html
├─ search/search.html
├─ tag/tag.html
├─ common/head.html
├─ common/header.html
├─ common/footer.html
└─ assets/style.css
页面类型
| 文件 | 适用页面 | 主要变量 |
|---|---|---|
index/index.html | 首页 | $category、$item、$i |
list/list.html | 栏目列表页 | $category、$list、分页 |
show/show.html | 文章详情页 | $article、$category |
search/search.html | 搜索结果 | $keyword、$list |
tag/tag.html | 标签聚合 | $tag、$list |
page/*.html | 单页 | $article |
公共片段
common/ 下放头部、页脚、侧栏等被多处引用的片段,用 include 引入:
{include file="common/header" /}
静态资源
<link rel="stylesheet" href="{pycms:theme_asset path="assets/style.css" /}">
theme_asset 会输出当前启用主题的静态资源地址,切换主题后无需改模板。
已是第一篇 theme.json 规范 →