Yelle🦋

Hexo 主题更换

参考文章 → butterfly配置 hexo_Hexo 完整使用教程 - 慕容圆月 - CSDN

参考文章 → Butterfly 安裝文檔(一) 快速開始 | Butterfly

下载主题

Themes | Hexo 中文文档 推荐:butterfly: 🦋 Butterfly 主题预览

pwd 在【blog】路径,输入 git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/Butterfly

手打一遍加载速度比较快

或者直接把主题下载到 blog/themes 文件夹里

修改配置文件

  • 使用 VS Code 修改 blog/_config.yml,翻到最下面把主题更换为 butterfly - 3.8.4
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/

theme: butterfly-3.8.4
  • 也可以使用 【Git Bash】 进入 blog 目录下 ls -l 展开所有项, vim _config.yml 修改
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/

theme: butterfly-3.8.4

为了减少升级主题后带来的不便,建议使用以下方法(此方法只支持 Hexo 5.0.0 以上版本):

在根目录创建 _config.butterfly.yml,把 themes 文件夹里的 _config.yml 复制到 _config.butterfly.yml去。

以后只需要在 _config.butterfly.yml 进行配置就行。 如果使用了 _config.butterfly.yml, 配置主题的 _config.yml 将不会有效果。

Hexo 会自动合并主题中的 _config.yml _config.butterfly.yml 里的配置,如果存在同名配置,會使用 _config.butterfly.yml 的配置,其优先度较高。

生成

hexo clean 清除旧的内容 hexo generate 重新生成发布用的静态页面 hexo server 本地运行一下 hexo deploy 在线应用

成功更换成 butterfly 主题🤩

报错解决

问题大多出现在 hexo deploy 这一步。

ERROR Deployer not found: git

  1. 安装 hexo-deployer-git npm install --save hexo-deployer-git
  2. _config.yml 配置中将 deploytype 改为git
deploy:
  type: git
  repo:git@github.com: 用户名/用户名.github.io.git
  branch: master

extends includes/layout.pug block content include ./includes/mixins/post-ui.pug #recent-posts.recent-posts +postUI include includes/pagination.pug

原因:沒有 pug 以及 stylus 的渲染器 在 Git Bash 中依次执行以下两条命令:

npm install hexo-renderer-pug hexo-renderer-stylus --save
npm install hexo-deployer-git --save / yarn add hexo-deployer-git

error:spawn failed...

参考文章 → hexo发生error:spawn failed错误的解决方法_HTL2018的博客-CSDN博客 成功解决。

  1. 删除【blog】下的 .deploy_git 文件夹
  2. 输入 git config --global core.autocrlf false

解决后依次执行

hexo clean
hexo g
hexo s
hexo d

本地预览成功,网页未更新

等待几分钟后,右键 刷新页面