Butterfly 主题页面配置
Front-matter 简介
Front-matter 是 Markdown 文件最上方以 --- 分隔的区域,用于指定个别文件的变量。
- Page Front-matter:用于页面配置
- Post Front-matter:用于文章页配置
页面 Front-matter 配置
基本结构
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| --- title: date: updated: type: comments: description: keywords: top_img: mathjax: katex: aside: aplayer: highlight_shrink: random: limit: type: value: ---
|
参数说明
| 参数 |
说明 |
| title |
【必需】页面标题 |
| date |
【必需】页面创建日期 |
| type |
【必需】标签、分类和友情链接三个页面需要配置 |
| updated |
【可选】页面更新日期 |
| description |
【可选】页面描述 |
| keywords |
【可选】页面关键字 |
| comments |
【可选】显示页面评论模块(默认 true) |
| top_img |
【可选】页面顶部图片 |
| mathjax |
【可选】显示 mathjax(当设置 mathjax 的 per_page: false 时才需要配置,默认 false) |
| katex |
【可选】显示 katex(当设置 katex 的 per_page: false 时才需要配置,默认 false) |
| aside |
【可选】显示侧边栏(默认 true) |
| aplayer |
【可选】在需要的页面加载 aplayer 的 js 和 css |
| highlight_shrink |
【可选】配置代码框是否展开(true/false,默认为设置中的配置) |
| random |
【可选】配置友情链接是否随机排序(默认 false) |
| limit |
【可选】配置说说显示数量 |
| limit.type |
【可选】配置说说显示数量的类型(date 或 num) |
| limit.value |
【可选】配置说说显示数量的值 |
文章 Front-matter 配置
基本结构
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| --- title: date: updated: tags: categories: keywords: description: top_img: comments: cover: toc: toc_number: toc_style_simple: copyright: copyright_author: copyright_author_href: copyright_url: copyright_info: mathjax: katex: aplayer: highlight_shrink: aside: abcjs: noticeOutdate: ---
|
参数说明
| 参数 |
说明 |
| title |
【必需】文章标题 |
| date |
【必需】文章创建日期 |
| updated |
【可选】文章更新日期 |
| tags |
【可选】文章标签 |
| categories |
【可选】文章分类 |
| keywords |
【可选】文章关键字 |
| description |
【可选】文章描述 |
| top_img |
【可选】文章顶部图片 |
| cover |
【可选】文章缩略图(如果没有设置 top_img,文章页顶部将显示缩略图) |
| comments |
【可选】显示文章评论模块(默认 true) |
| toc |
【可选】显示文章目录(默认为设置中的配置) |
| toc_number |
【可选】显示目录编号(默认为设置中的配置) |
| toc_style_simple |
【可选】显示目录简洁模式 |
| copyright |
【可选】显示文章版权模块(默认为设置中的配置) |
| copyright_author |
【可选】文章版权模块的作者 |
| copyright_author_href |
【可选】文章版权模块的作者链接 |
| copyright_url |
【可选】文章版权模块的文章链接 |
| copyright_info |
【可选】文章版权模块的版权声明文字 |
| mathjax |
【可选】显示 mathjax |
| katex |
【可选】显示 katex |
| aplayer |
【可选】在需要的页面加载 aplayer |
| highlight_shrink |
【可选】配置代码框是否展开 |
| aside |
【可选】显示侧边栏(默认 true) |
| abcjs |
【可选】加载 abcjs |
| noticeOutdate |
【可选】文章过期提醒 |
标签页配置
创建标签页
- 在 Hexo 根目录执行:
hexo new page tags
- 找到
source/tags/index.md 文件
- 修改文件内容:
1 2 3 4 5 6 7
| --- title: 标签 date: 2024-01-01 00:00:00 type: 'tags' orderby: random order: 1 ---
|
标签页参数
| 参数 |
说明 |
| type |
【必须】页面类型,必须为 tags |
| orderby |
【可选】排序方式:random(随机)/ name(名称)/ length(数量) |
| order |
【可选】排序顺序:1(升序)/ -1(降序) |
分类页配置
创建分类页
- 在 Hexo 根目录执行:
hexo new page categories
- 找到
source/categories/index.md 文件
- 修改文件内容:
1 2 3 4 5
| --- title: 分类 date: 2024-01-01 00:00:00 type: 'categories' ---
|
友情链接页配置
创建友情链接页
- 在 Hexo 根目录执行:
hexo new page link
- 找到
source/link/index.md 文件
- 修改文件内容:
1 2 3 4 5
| --- title: 友情链接 date: 2024-01-01 00:00:00 type: 'link' ---
|
本地数据源配置
在 source/_data/link.yml 中配置(如果没有 _data 文件夹,请自行创建):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| - class_name: 友情链接 class_desc: 那些人,那些事 link_list: - name: Hexo link: https://hexo.io/ avatar: https://d33wubrfki0l68.cloudfront.net/logo.svg descr: 快速、简单且强大的网志框架
- class_name: 网站 class_desc: 值得推荐的网站 link_list: - name: Github link: https://github.com/ avatar: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png descr: 代码托管平台
|
远程数据源配置
从 4.0.0 版本开始,支持从远程加载友情链接(仅支持 JSON 格式)。
在 source/link/index.md 的 front-matter 中添加:
1
| flink_url: https://example.com/links.json
|
友情链接随机排序
在 front-matter 中添加 random: true 即可启用随机排序。
404 页面配置
主题内置了一个简单的 404 页面,可在配置中开启:
1 2 3 4
| error_404: enable: true subtitle: '页面没有找到' background: /img/error-page.png
|
本地预览时,访问 http://localhost:4000/404.html 可以查看 404 页面。
说说页面配置
创建说说页面
- 在 Hexo 根目录执行:
hexo new page shuoshuo
- 找到
source/shuoshuo/index.md 文件
- 修改文件内容:
1 2 3 4 5
| --- title: 说说 date: 2024-01-01 00:00:00 type: 'shuoshuo' ---
|
说说数据源配置
在 source/_data/shuoshuo.yml 中配置:
1 2 3 4 5 6 7 8 9 10
| - author: 作者名 avatar: https://example.com/avatar.png date: 2024-01-01 12:00:00 key: key-1 content: | 这是说说内容 支持 Markdown 格式 tags: - 标签1 - 标签2
|
说说参数说明
| 参数 |
说明 |
| author |
【可选】作者名称 |
| avatar |
【可选】作者头像 |
| date |
【必需】日期 |
| content |
【必需】内容(Markdown 或 HTML 格式) |
| key |
【可选】评论的唯一标识,启用评论必须配置 |
| tags |
【可选】标签 |
图库页面配置
图库页面是普通的页面,使用标签插件 galleryGroup 来展示图片分组。
总结
通过合理配置 Front-matter 和各种页面类型,你可以充分利用 Butterfly 主题的功能,创建一个功能完整、内容丰富的博客。