Hexo Butterfly 主题副标题不显示问题解决方案
问题描述
在 Hexo 根目录的_config.yml中配置了subtitle,但网站没有显示副标题。
问题原因
配置位置错误!
Butterfly 主题的副标题配置不在 Hexo 根目录的_config.yml中,而是在主题配置文件themes/butterfly/_config.yml中。
错误的配置方式 ❌
在 Hexo 根目录_config.yml中配置:
title:Aetik's Blog🍉subtitle:欢迎来到 Aetik 的博客🍉# ← 这样配置不会生效!正确的配置方式 ✅
在主题配置文件themes/butterfly/_config.yml中配置:
subtitle:enable:trueeffect:truesource:falsesub:-欢迎来到 Aetik 的博客🍉解决方案
步骤 1:找到主题配置文件
打开themes/butterfly/_config.yml文件
步骤 2:定位到 subtitle 配置
找到第 169-187 行左右的配置:
# The subtitle on homepagesubtitle:enable:true# Typewriter Effecteffect:true# Customize typed.jstyped_option:# Source - Call the third-party service API (Chinese only)source:false# If you close the typewriter effect, the subtitle will only show the first line of subsub:# ← 这里是空的!步骤 3:添加副标题内容
在sub:下面添加你的副标题:
sub:-欢迎来到 Aetik 的博客🍉步骤 4:重新生成网站
hexo clean hexo g hexo s配置说明
完整配置示例
1. 静态副标题(无动画)
subtitle:enable:trueeffect:false# 关闭打字机效果source:falsesub:-欢迎来到 Aetik 的博客🍉2. 打字机动画效果
subtitle:enable:trueeffect:true# 启用打字机效果source:falsesub:-欢迎来到 Aetik 的博客🍉-你在抱怨什么呢-为明天到来的事,说人生像是没有意义-没有选择会是唯一的路3. 使用第三方 API(一言)
subtitle:enable:trueeffect:truesource:1# 1 = hitokoto.cn 一言sub:-默认副标题可用的 API 源:
false- 不使用 API,只显示sub中的内容1- hitokoto.cn(一言)2- https://api.aa1.cn/doc/yiyan.html3- jinrishici.com(今日诗词)
配置参数详解
| 参数 | 说明 | 可选值 |
|---|---|---|
enable | 是否启用副标题 | true/false |
effect | 是否启用打字机动画效果 | true/false |
typed_option | 自定义 typed.js 配置 | 参考 typed.js 文档 |
source | 第三方 API 源 | false/1/2/3 |
sub | 副标题内容数组 | 字符串数组 |
常见问题
Q1: 为什么我配置了还是不显示?
检查清单:
- 是否在正确的文件(
themes/butterfly/_config.yml)中配置 enable是否设置为truesub是否有内容(不能为空)- 是否执行了
hexo clean && hexo g
Q2: 如何实现多个副标题轮播?
在sub中添加多个条目:
sub:-第一个副标题-第二个副标题-第三个副标题Q3: 如何关闭打字机效果,显示静态副标题?
subtitle:enable:trueeffect:false# 关闭动画sub:-静态副标题Q4: 副标题显示优先级是怎样的?
如果配置了sourceAPI:
- 优先显示 API 返回的内容
- 然后显示
sub中的内容
最佳实践
推荐配置方式
使用_config.butterfly.yml文件(主题升级时配置不会丢失):
- 在 Hexo 根目录创建
_config.butterfly.yml - 添加配置:
subtitle:enable:trueeffect:truesource:falsesub:-欢迎来到 Aetik 的博客🍉配置优先级
_config.butterfly.yml > themes/butterfly/_config.yml效果展示
打字机效果
- 副标题会像打字一样逐字显示
- 显示完成后会删除并重新显示
- 支持多个副标题轮播
静态效果
- 直接显示副标题文本
- 无动画效果
参考资料
- Butterfly 主题官方文档
- Butterfly 主题配置文件详解
- typed.js 文档
更新日期
2026-03-16
适用版本
- Hexo 5.0.0+
- Butterfly Theme 3.0+
