Butterfly 主题配置指南
主题概述
Butterfly 是一款基于 hexo-theme-melody 开发的 Hexo 主题,具有简洁的卡片式 UI 设计。
官方文档: https://butterfly.js.org/
GitHub: https://github.com/jerryc127/hexo-theme-butterfly
当前版本: 5.5.4
主题安装
方式一:npm 安装(推荐)
1
| npm install hexo-theme-butterfly
|
升级方法:
1
| npm update hexo-theme-butterfly
|
方式二:Git 安装
1 2 3 4 5
| git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
|
升级方法:在主题目录下运行 git pull
应用主题
修改 Hexo 根目录下的 _config.yml:
安装渲染插件
1
| npm install hexo-renderer-pug hexo-renderer-stylus --save
|
配置文件说明
配置文件优先级
Hexo 会自动合并主题配置,优先级从高到低:
_config.butterfly.yml(根目录,推荐使用)themes/butterfly/_config.yml(主题目录)
建议: 在 Hexo 根目录创建 _config.butterfly.yml 文件,将主题配置放在这里,方便升级。
配置文件结构
1 2 3 4 5 6
| HexoBlogDemo/ ├── _config.yml # Hexo 主配置 ├── _config.butterfly.yml # Butterfly 主题配置(推荐) └── themes/ └── butterfly/ └── _config.yml # 主题默认配置
|
导航栏配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| nav: logo: display_title: true display_post_title: true fixed: true
menu: Home: / || fas fa-home Archives: /archives/ || fas fa-archive Tags: /tags/ || fas fa-tags Categories: /categories/ || fas fa-th About: /about/ || fas fa-heart
|
图标说明
使用 Font Awesome 图标:https://fontawesome.com/icons
常用图标:
fas fa-home - 首页fas fa-archive - 归档fas fa-tags - 标签fas fa-th - 分类fas fa-heart - 关于fas fa-user - 用户fas fa-book - 书fas fa-code - 代码
子菜单
1 2 3 4
| menu: List||fas fa-list: Music: /music/ || fas fa-music Movies: /movies/ || fas fa-video
|
代码块配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| code_blocks: theme: light macStyle: false height_limit: false word_wrap: false
copy: true language: true shrink: false fullpage: false
|
代码高亮配置
在 Hexo 根目录 _config.yml 中配置:
1 2 3 4 5 6
| syntax_highlighter: prismjs prismjs: preprocess: true line_number: true tab_replace: ''
|
图片配置
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 28 29 30 31 32 33 34 35 36 37 38 39 40
| favicon: /img/favicon.png
avatar: img: /img/my-avatar.png effect: false
disable_top_img: false
default_top_img:
index_img: /img/bg.jpg
archive_img:
tag_img:
tag_per_img:
category_img:
category_per_img:
footer_img: false
background: /img/boat.jpg
|
封面设置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| cover: index_enable: true aside_enable: true archives_enable: true position: both default_cover:
|
错误图片
1 2 3 4 5 6 7 8 9
| error_img: flink: /img/friend_404.gif post_page: /img/404.jpg
error_404: enable: false subtitle: 'Page Not Found' background: /img/error-page.png
|
文章元数据配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| post_meta: page: date_type: created date_format: date categories: true tags: false label: true
post: position: left date_type: both date_format: date categories: true tags: true label: true
|
首页配置
副标题打字效果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| subtitle: enable: true effect: true typed_option: typeSpeed: 100 backSpeed: 50 loop: false backDelay: 1000 startDelay: 500 source: false sub: - "Henry的技术小酒馆,séi来都得醉"
|
首页文章布局
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
index_layout: 3
index_post_content: method: 3 length: 500
|
文章页配置
目录 (TOC)
1 2 3 4 5 6 7
| toc: post: true page: false number: true expand: false style_simple: false scroll_percent: true
|
版权声明
1 2 3 4 5 6
| post_copyright: enable: true decode: false author_href: license: CC BY-NC-SA 4.0 license_url: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
打赏功能
1 2 3 4 5 6 7 8 9 10
| reward: enable: false text: QR_code: - img: /img/wechat.jpg link: text: 微信 - img: /img/alipay.jpg link: text: 支付宝
|
相关文章
1 2 3 4
| related_post: enable: true limit: 6 date_type: created
|
文章分页
过期提醒
1 2 3 4 5 6 7
| noticeOutdate: enable: false style: flat limit_day: 365 position: top message_prev: It has been message_next: days since the last update, the content may be outdated.
|
页脚配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| footer: nav: owner: enable: true since: 2026 copyright: enable: false version: false custom_text: | <a href="https://beian.miit.gov.cn/" target="_blank">陕ICP备XXXXXXXX号-1</a> <span class="footer-separator"> | </span> <a href="https://github.com/Dhongli" target="_blank">Henry Dai</a> <span class="footer-separator"> | </span> <a href="/" target="_blank">Copyright © 2026</a>
|
侧边栏配置
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| aside: enable: true hide: false button: true mobile: true position: right display: archive: true tag: true category: true
card_author: enable: true description: button: enable: true icon: fab fa-github text: Follow Me link: https://github.com/Dhongli
card_announcement: enable: true content: Henry的技术小酒馆,séi来都得醉
card_recent_post: enable: true limit: 5 sort: date sort_order:
card_newest_comments: enable: false sort_order: limit: 6 storage: 10 avatar: true
card_categories: enable: true limit: 8 expand: none sort_order:
card_tags: enable: true limit: 40 color: false custom_colors: orderby: random order: 1 sort_order:
card_archives: enable: true type: monthly format: MMMM YYYY order: -1 limit: 8 sort_order:
card_webinfo: enable: true post_count: true last_push_date: true sort_order: runtime_date:
|
右下角按钮配置
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
| translate: enable: false default: 繁 defaultEncoding: 2 translateDelay: 0 msgToTraditionalChinese: '繁' msgToSimplifiedChinese: '簡'
readmode: true
darkmode: enable: true button: true autoChangeMode: false start: end:
rightside_scroll_percent: false
|
全局设置
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
| anchor: auto_update: false click_to_scroll: false
photofigcaption: false
copy: enable: true copyright: enable: false limit_count: 150
wordcount: enable: false post_wordcount: true min2read: true total_wordcount: true
busuanzi: site_uv: true site_pv: true page_pv: true
|
数学公式配置
1 2 3 4 5 6 7 8 9 10 11 12
| math: use: per_page: true hide_scrollbar: false
mathjax: enableMenu: true tags: none
katex: copy_tex: false
|
搜索配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| search: use: local_search placeholder: 搜索文章... placement: right trigger: click
local_search: preload: true top_n_per_article: 1 unescape: false pagination: enable: false hitsPerPage: 8 CDN:
|
分享配置
1 2 3 4 5 6 7 8 9
| share: use: sharejs
sharejs: sites: wechat,weibo,qq
addtoany: item: facebook,x,wechat,sina_weibo,facebook_messenger,email,copy_link
|
评论系统配置
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 28 29 30 31 32
| comments: use: text: true lazyload: false count: false card_post_count: false
twikoo: envId: region: visitor: false option:
giscus: repo: repo_id: category_id: light_theme: light dark_theme: dark js: option:
waline: serverURL: bg: pageview: false option:
|
统计分析配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| baidu_analytics:
google_analytics:
cloudflare_analytics:
microsoft_clarity:
umami_analytics: enable: false serverURL: script_name: script.js website_id: option: UV_PV: site_uv: false site_pv: false page_pv: false token:
|
CDN 配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| CDN: internal_provider: local third_party_provider: jsdelivr version: true custom_format: option:
|
自定义注入
1 2 3 4 5 6 7 8 9
| inject: head: - <link rel="stylesheet" href="/css/custom.css"> bottom: - <script src="/js/custom.js"></script>
|
背景特效配置
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 28 29 30 31 32 33 34 35 36 37 38 39
| canvas_ribbon: enable: false size: 150 alpha: 0.6 zIndex: -1 click_to_change: false mobile: false
canvas_nest: enable: false color: '100,100,100' opacity: 0.25 zIndex: -1 count: 99 mobile: false
fireworks: enable: false zIndex: 9999 mobile: false
click_heart: enable: false mobile: false
clickShowText: enable: false text: fontSize: 15px random: false mobile: false
|
其他配置
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| pjax: enable: false exclude:
lightbox:
note: style: flat icons: true border_radius: 3 light_bg_offset: 0
mermaid: enable: false code_write: false theme: light: default dark: dark open_in_new_tab: true zoom_pan: true
lazyload: enable: false native: false field: site placeholder: blur: false
pwa: enable: false manifest: apple_touch_icon: favicon_32_32: favicon_16_16: mask_icon:
Open_Graph_meta: enable: true option:
structured_data: enable: false alternate_name:
css_prefix: true
preloader: enable: false source: 1
enter_transitions: true
display_mode: light
|
常用主题页面
友情链接页
编辑 source/link/index.md:
1 2 3 4 5
| --- title: 友情链接 date: 2026-06-19 type: "link" ---
|
图库页
说说页
升级注意事项
- 备份配置: 升级前备份
_config.butterfly.yml - 查看更新日志: https://butterfly.js.org/posts/198a4240/
- 合并配置: 新版本可能有配置变更,需要手动合并
- 测试: 升级后本地测试确认无误再部署
参考资源