butterfly主题在hexo中的配置
1. 安装Butterfly主题
方法一:Git克隆(推荐)
bash
cd themes
git clone https://github.com/jerryc127/hexo-theme-butterfly.git
–depth=1
方法二:手动下载
- 从Butterfly Releases下载最新版
- 解压到
themes/butterfly目录
2. 去除子模块绑定
步骤说明
bash
解除子模块关联
git rm –cached themes/butterfly
rm -rf themes/butterfly/.git
清理残留配置(可选)
git config -f .gitmodules –remove-section submodule.themes/butterfly
rm -rf .git/modules/themes/butterfly
文件结构验证
确保处理后目录包含:
themes/butterfly/
├── _config.yml # 主配置文件(27KB)
├── layout/ # 模板文件
├── source/ # 静态资源
├── scripts/ # 脚本文件
└── languages/ # 多语言文件
3. 推送到GitHub仓库
配置Hexo
修改_config.yml:
yaml
theme: butterfly
提交变更
bash
git add themes/butterfly
git commit -m “feat: 添加butterfly主题并解除子模块”
git push origin main
4. 主题更新方法
手动更新
- 备份
_config.yml和自定义文件 - 覆盖
themes/butterfly目录 - 恢复配置文件
自动化建议
yaml
.github/workflows/update-theme.yml
jobs:
update:
steps:
uses: actions/checkout@v4
run: |
rm -rf themes/butterfly
git clone https://github.com/jerryc127/hexo-theme-butterfly
themes/butterfly
cp custom_config.yml themes/butterfly/_config.yml
注意事项
- 操作前备份
_config.yml(27KB配置文件) - 不要提交
themes/butterfly/.github/目录 - 使用
.gitignore过滤临时文件:
themes/butterfly/.github/
themes/butterfly/node_modules/
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 长夜小屋!
