首页与文章页
配置首页布局形态、Hero 大卡、置顶、摘要策略,以及文章页的目录、meta、版权、打赏、相关文章。
首页与文章页
首页(Blog 模式)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| index: layout: card hero: true sticky: true excerpt: excerpt excerpt_length: 140 cover: true per_page: alternate_layout: true
|
列表形态 layout
| 值 |
表现 |
适合 |
card |
大卡片,带封面、摘要、meta |
默认,视觉优先 |
list |
紧凑列表,信息密度高 |
文章多、偏工具站 |
grid |
网格排列,一屏多篇 |
图片内容、作品集 |
classic |
传统单列,标题 + 摘要 |
极简偏好 |
Hero 大卡
开启后首页顶部渲染一块欢迎区:头像 + 站点标题 + 标语 + 数据统计(文章数 / 分类数 / 标签数,若开启 vendors.busuanzi 还会显示 PV)。
标题与副标题的取值优先级:
1 2
| theme.hero_title > config.title theme.hero_subtitle > theme.tagline > config.subtitle
|
Hero 只在第一页显示(模板判定 page.current === 1)。移动端可以通过组件开关单独关掉:
1 2 3 4
| adaptive: tiers: mobile: disable: [hero]
|
置顶
在文章的 front-matter 里加权重即可:
1 2 3 4
| --- title: 重要公告 sticky: 100 ---
|
数值越大越靠前,非置顶文章始终排在置顶文章之后。若只想让某篇”浮”到不置顶内容的最前面,给个较小的数(如 10)即可。
摘要策略
| 值 |
行为 |
excerpt |
取 <!-- more --> 之前的内容;没有标记则取 post.excerpt |
auto |
从正文剥离标签后截取 excerpt_length 个字符,超出加省略号 |
none |
不显示摘要 |
手动摘要是最优解
excerpt 模式下,在正文里合适的位置插入 <!-- more -->,首页卡片就显示到这里为止。这比自动截取更可控——不会在句子中间断开。
条目数与交替布局
1 2 3
| index: per_page: 10 alternate_layout: true
|
alternate_layout: true 时,相邻的带图卡片会左右交替排布,避免视觉单调。
文章页
1 2 3 4 5 6 7 8 9
| post: toc: true toc_depth: [2, 3, 4] toc_wrap: true breadcrumb: true
|
目录
| 配置项 |
说明 |
toc |
总开关。单篇可用 front-matter toc: false 覆盖 |
toc_depth |
目录收录的标题层级。[2, 3] 表示只收 H2 与 H3 |
toc_wrap |
长标题是否折行显示,关闭则省略号截断 |
目录出现在哪里取决于模式:
| 模式 |
目录位置 |
| blog |
右侧挂件栏内的 toc 挂件 |
| notes |
独立右侧目录栏(notes.toc 控制) |
| docs |
独立右侧目录栏(docs.toc 控制) |
三种形态下,目录都具备滚动跟随高亮与自动滚入可见区的能力。在手机档,目录被折叠为正文顶部的面板,点击标题头展开。
1 2 3 4 5 6 7 8
| post: meta: - author - date - updated - categories - wordcount - reading
|
顺序即显示顺序。可选项:author date updated categories wordcount reading。删掉某项即隐藏。
相关的辅助配置:
1 2 3 4
| post: show_updated: true wordcount: true words_per_minute: 350
|
字数与阅读时长怎么算的
主题用 xfm_wordcount() 统计:中日韩字符按每个字符计 1 字,拉丁文按按单词计 1 字。阅读时长 = 字数 ÷ words_per_minute,向上取整且至少 1 分钟。words_per_minute 默认 350(中文阅读速度),英文站可调到 200 左右。
上下篇与版权
1 2 3 4 5 6 7 8 9
| post: post_nav: true copyright: true copyright_text: 本文为原创内容,转载请注明出处:{link} tags: true
|
copyright_text 中的 {link} 会被替换为指向本文的 <a> 链接。
打赏
1 2 3 4 5
| post: reward: false reward_text: 如果这篇文章对你有帮助,可以请我喝杯咖啡。 reward_wechat: reward_alipay:
|
开启后文章底部出现”打赏”按钮,点击展开付款码。微信与支付宝可分别配置,都留空则只显示文案。
相关文章
1 2 3
| post: related_posts: true related_count: 4
|
推荐算法基于标签与分类权重:同标签 +2 分,同分类 +3 分,按总分降序取前 N 篇。所以给文章打好标签、归好分类,是相关推荐质量的前提。
分享
1 2 3 4 5 6 7 8 9
| share: services: - copy - weibo - qq - twitter qrcode: true
|
copy 是复制链接按钮,qrcode 是弹出二维码。文章页的分享组由 post.share 总开关控制。
面包屑
开启后在正文上方显示路径导航(首页 / 分类 / 当前文章)。文档与笔记模式下同样生效,有助于读者定位自己在文档树中的位置。
阅读体验
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| reading: progress_bar: true reading_time: true back_to_top: true zoom_image: true scheme_toggle: true outdated_notice: false outdated_days: 365 smooth_scroll: true
|
| 配置项 |
说明 |
progress_bar |
页面顶部细进度条,随滚动填充 |
reading_time |
基于 words_per_minute 估算 |
back_to_top |
滚动超过 320px 时出现 |
zoom_image |
点击图片打开灯箱(需 vendors.lightbox: true) |
outdated_notice |
文章距最后更新超过 outdated_days 天时,正文顶部插一条黄色提示 |
smooth_scroll |
锚点跳转平滑滚动,并自动补偿导航栏高度 |
文档站建议关掉过时提醒
文档是”长期有效”的内容,outdated_notice 更适合博客。文档站保持 false 可避免读者误以为内容失效。
分类 / 标签 / 归档页
1 2 3 4 5 6 7 8 9 10 11 12 13
| taxonomy: tag_cloud: true category_cloud: true archive_group: true archive_yearly: true timeline_style: true layout: timeline
|
对应的页面需要手动创建(见安装与部署):
1 2 3
| hexo new page tags hexo new page categories hexo new page archives
|
评论