初始化博客

1
hexo init 

安装butterfly主题

1
2
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
npm install hexo-renderer-pug hexo-renderer-stylus --save

配置_config.yml

1
2
3
4
5
deploy:
type: git
repo: https://github.com/xxx/xxx.github.io.git
branch: main
token: ghxxxxxxxxxxxxxxxxxxxxxxxxxii

安装部署工具

1
npm install hexo-deployer-git --save

本地测试

1
hexo s

部署至git page

1
hexo d

升级主题

在主题文件夹下执行

1
git pull

升级Hexo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 使用淘宝源的 cnpm 替换 npm(如果直接用 npm 执行更新命令,大概率会更新失败)
npm install -g cnpm --registry=https://registry.npm.taobao.org
# 升级 cnpm
cnpm install -g cnpm
# 清除缓存
cnpm cache clean -f

# 进入 Hexo 根目录,执行如下命令
# 更新 package.json 中的 Hexo 及各个插件版本
cnpm install -g npm-check # 检查之前安装的插件,都有哪些是可以升级的
cnpm install -g npm-upgrade # 升级系统中的插件
npm-check
npm-upgrade

# 更新 Hexo 及所有插件
cnpm update

# 确认 Hexo 已经更新
hexo -v

一键脚本

1
2
3
4
5
6
7
8
hexo init
cnpm install hexo-renderer-pug;
cnpm install hexo-deployer-git;
cnpm install hexo-generator-baidu-sitemap;
cnpm install hexo-generator-sitemap;
cnpm install hexo-math;
cnpm install hexo-wordcount;
git clone https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly