一、安装主题

  1. 打开运行窗口:

    • 快捷键:Windows + R
    • 输入 cmd 并点击“确定”
  2. 在命令提示符中输入以下命令进入 Hexo 项目目录:

    1
    cd hexo
  3. 克隆 Butterfly 主题:

    1
    git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
  4. (可选)清屏:

    1
    cls

二、配置 Hexo 主配置文件

  1. 打开路径:C:\Users\Administrator\hexo

  2. 右键点击 _config.yml,使用记事本打开

  3. 使用快捷键 Ctrl + F,查找内容:

    1
    theme
  4. 点击“查找下一个”,定位到:

    1
    theme: landscape
  5. 修改为:

    1
    theme: butterfly

三、安装依赖插件

1
npm install hexo-renderer-pug hexo-renderer-stylus --save

四、复制 Butterfly 默认配置文件

1
copy "themes\butterfly\_config.yml" "_config.butterfly.yml"

五、配置 Git 子模块(可选)

  1. 创建 .gitmodules 文件:

    1
    echo. > .gitmodules
  2. 打开路径:C:\Users\Administrator\hexo,双击 .gitmodules 文件,添加以下内容:

    1
    2
    3
    [submodule "themes/butterfly"]
    path = themes/butterfly
    url = https://github.com/jerryc127/hexo-theme-butterfly.git
  3. 提交配置到 Git:

    1
    2
    3
    git add .gitmodules
    git commit -m "Add .gitmodules file"
    git push origin main
  4. 初始化并拉取子模块:

    1
    2
    git submodule init
    git submodule update --recursive
  5. 添加并提交子模块改动:

    1
    2
    3
    git 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
2
3
4
5
6
7
title: 网络技术分享笔记
subtitle: 探索前沿,分享实践
description: "无界互联,助你探索更多可能。"
keywords: 技术, 编程, 开发, 网络安全
author: weige
language: zh-CN
timezone: Asia/Shanghai

八、配置 Butterfly 主题(_config.butterfly.yml)

主题配置文档地址:https://butterfly.js.org/

1. Logo 配置

1
2
3
4
5
nav:
logo: https://pic.520155.xyz/file/1752351600600_飞天猫.png
display_title: false
display_post_title: true
fixed: false

2. 导航菜单配置

默认配置如下(注释状态):

1
2
3
4
5
menu:
# Home: / || fas fa-home
# List||fas fa-list:
# Music: /music/ || fas fa-music
# Movie: /movies/ || fas fa-video

替换为:

1
2
3
4
5
menu:
主页: / || fas fa-home
分类: /categories/ || fas fa-th
说说: /talk/ || fas fa-comments
云盘: https://yourcloud.example.com || fas fa-cloud

九、部署及一键操作命令

单步命令(推荐新手)

1
2
3
4
5
hexo generate
hexo deploy
git add .
git commit -m "update"
git push origin main

一条命令更新全部:

1
cd hexo && hexo clean && hexo generate && hexo deploy && git add . && git commit -m "update" && git push origin main

十、返回上级目录(可选)

1
cd ..