前言
文章页是博客的核心页面,良好的配置可以提升阅读体验。本文将介绍代码块样式、文章元信息、目录、相关文章、版权信息、字数统计和访问统计等配置。
一、代码块配置
1 2 3 4 5 6 7 8 9 10
| code_blocks: theme: darker macStyle: true height_limit: 300 word_wrap: false copy: true language: true shrink: false fullpage: false
|
提示: macStyle: true 会让代码块顶部显示 Mac 风格的红绿黄按钮,视觉效果更好。
二、文章元信息
2.1 页面元信息
1 2 3 4 5 6 7
| post_meta: page: date_type: updated date_format: relative categories: true tags: true label: true
|
2.2 文章元信息
1 2 3 4 5 6 7
| post_meta: post: date_type: both date_format: relative categories: true tags: true label: true
|
三、文章目录
1 2 3 4 5 6 7 8
| toc: post: true page: true number: false expand: false style_simple: false scroll_percent: true
|
四、相关文章
1 2 3 4 5
| related_post: enable: true limit: 6 date_type: created
|
相关文章会自动根据标签和分类推荐相似内容。
五、文章版权信息
1 2 3 4 5 6 7
| post_copyright: enable: true decode: true author_href: license: CC BY-NC-SA 4.0 license_url: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
开启后,文章底部会显示版权声明,包括作者、链接、许可证等信息。
六、数学公式支持(KaTeX)
1 2 3 4 5
| katex: enable: true per_page: true hide_scrollbar: false
|
开启后可以在文章中使用 LaTeX 数学公式:
1 2 3 4 5 6
| 行内公式:$E = mc^2$
独立公式: $$ \sum_{i=1}^{n} x_i = x_1 + x_2 + \cdots + x_n $$
|
七、字数统计
1 2 3 4 5 6
| wordcount: enable: true post_wordcount: true min2read: true total_wordcount: true
|
八、访问统计
8.1 不蒜子统计
1 2 3 4 5
| busuanzi: site_uv: true site_pv: true page_pv: true
|
8.2 浏览器标签页图标
1 2
| favicon: /img/favicon.jpg
|
九、返回顶部按钮
1 2
| rightside_scroll_percent: true
|
总结
文章页的配置直接影响阅读体验。建议开启目录、字数统计和版权信息,这些功能对读者非常友好。KaTeX 数学公式对技术博客尤其重要。
参考资料: