安装 Node.js

使用 nvm 安装,Github 链接

最好装一个 Windows Terminal,安装完后输入 nvm version 查看是否安装成功。

1
2
nvm version
# 1.1.9

安装 Node.js 并选择需要的版本。若报错,以管理员身份运行。

1
2
nvm install 16.15.0
nvm use 16.15.0

安装 Git

直接去 Git 官网下载,全部默认安装就行。

安装 Hexo

1
npm install -g hexo-cli

查看是否安装成功

1
hexo -v

如果以下错误

1
2
3
4
5
6
7
hexo : 无法加载文件 C:\Program Files\nodejs\hexo.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.micros
oft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ hexo -v
+ ~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

执行

1
set-executionpolicy remotesigned

再查看版本即可

1
2
hexo -v
# hexo-cli: 4.3.0

新建博客文件夹,切换到此路径,执行 Hexo 初始化。

1
hexo init

本地运行,此时可以看见博客界面了

1
hexo s

安装 Butterfly 主题

1
2
3
4
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly

# 安装渲染插件
npm install hexo-renderer-pug hexo-renderer-stylus --save

安装其他所需插件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# katex 插件
npm un hexo-renderer-marked --save # 如果有安装这个的话,卸载
npm un hexo-renderer-kramed --save # 如果有安装这个的话,卸载
npm install hexo-renderer-markdown-it --save # 需要安装这个渲染插件
npm install @neilsustc/markdown-it-katex --save #需要安装这个 katex 插件
npm install markdown-it-task-checkbox --save # 任务列表插件

# 并开启插件
# markdown:
# plugins:
# - plugin:
# name: '@neilsustc/markdown-it-katex'
# options:
# strict: false
# - markdown-it-emoji
# - markdown-it-task-checkbox

# 文章字数统计插件
npm install hexo-wordcount --save

# git 部署插件
npm install hexo-deployer-git --save

# 浏览器自动同步插件
npm install hexo-browsersync --save

# 短链生成插件
npm install hexo-abbrlink --save

# 本地搜索插件
npm install hexo-generator-search --save

部署到 Github

1
hexo d

若报以下错误,是因为没有配置 git。

1
2
3
4
5
6
7
8
9
10
11
Initialized empty Git repository in C:/Users/USER/Desktop/blog_source/.deploy_git/.git/
Author identity unknown
*** Please tell me who you are.
Run

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'USER@202-030.(none)')

执行

1
2
3
4
5
6
git config --global user.email "you@example.com"
git config --global user.name "Your Name"

# 比如
git config --global user.email 10001@qq.com
git config --global user.name xiaomage

再次执行 hexo d 时,会弹出 Github 登录窗口,登录即可部署。

将 rsa 添加到 Github