安装并配置 Hexo 的 Butterfly 主题
一、安装主题
打开运行窗口:
- 快捷键:
Windows + R - 输入
cmd并点击“确定”
- 快捷键:
在命令提示符中输入以下命令进入 Hexo 项目目录:
1
cd hexo
克隆 Butterfly 主题:
1
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
(可选)清屏:
1
cls
二、配置 Hexo 主配置文件
打开路径:
C:\Users\Administrator\hexo右键点击
_config.yml,使用记事本打开使用快捷键
Ctrl + F,查找内容:1
theme
点击“查找下一个”,定位到:
1
theme: landscape
修改为:
1
theme: butterfly
三、安装依赖插件
1 | npm install hexo-renderer-pug hexo-renderer-stylus --save |
四、复制 Butterfly 默认配置文件
1 | copy "themes\butterfly\_config.yml" "_config.butterfly.yml" |
五、配置 Git 子模块(可选)
创建
.gitmodules文件:1
echo. > .gitmodules
打开路径:
C:\Users\Administrator\hexo,双击.gitmodules文件,添加以下内容:1
2
3[submodule "themes/butterfly"]
path = themes/butterfly
url = https://github.com/jerryc127/hexo-theme-butterfly.git提交配置到 Git:
1
2
3git add .gitmodules
git commit -m "Add .gitmodules file"
git push origin main初始化并拉取子模块:
1
2git submodule init
git submodule update --recursive添加并提交子模块改动:
1
2
3git add themes/butterfly
git commit -m "Add butterfly theme as submodule"
git push origin main
六、验证主题是否生效
打开浏览器,访问:
1 | https://site.520155.xyz/ |
七、完善站点信息(修改 _config.yml)
路径:C:\Users\Administrator\hexo
右键点击 _config.yml 用记事本打开,找到 Site 部分,修改为:
1 | title: 网络技术分享笔记 |
八、配置 Butterfly 主题(_config.butterfly.yml)
主题配置文档地址:https://butterfly.js.org/
1. Logo 配置
1 | nav: |
2. 导航菜单配置
默认配置如下(注释状态):
1 | menu: |
替换为:
1 | menu: |
九、部署及一键操作命令
单步命令(推荐新手)
1 | hexo generate |
一条命令更新全部:
1 | cd hexo && hexo clean && hexo generate && hexo deploy && git add . && git commit -m "update" && git push origin main |
十、返回上级目录(可选)
1 | cd .. |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 null!
