安装nodejs环境

安装nodejs 24.12 LTS

1
2
3
4
5
6
7
# 升级软件包
sudo apt update
sudo apt upgrade -y
# 安装nodejs 24LTS
sudo apt install -y node npm
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
sudo apt install -y nodejs

2. 初始化Hexo

1
2
3
4
5
6
7
8
# 创建blog文件夹
mkdir blog && cd blog
# 初始化
hexo init
# 编译
hexo g
# 部署
hexo s

3. butterfiy主题

3.1 安装主题

1
2
3
4
# 安装主题依赖
npm install hexo-renderer-pug hexo-renderer-stylus
# 安装主题
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly

3.2 配置主题

打开blog目录下的_config.yml配置文件,修改成theme: butterfly

4. 配置Github

1
2
# 安装依赖
npm install hexo-deployer-git --save

创建一个仓库,命名方式为你的github用户名.github.io,复制https地址,打开本地博客的配置文件_config.yml,在deploy下输入以下内容:

1
2
3
4
deploy:
type: 'git'
repo: https://github.com/aa/aa.github.io.git
branch: main

配置 Git 身份信息,在终端运行以下两条命令

1
2
3
4
# 配置Github信息
git config --global user.email "your_email@example.com"
git config --global user.name "Your Name"
git config --global credential.helper store

配置Github TOKEN,进入GitHub -> Settings -> Developer settings -> Personal access tokens -> Tokens (classic)

1
2
3
# 重新部署并上传Github
hexo clean && hexo g && hexo d
#根据提示输入Github的邮箱和上述TOKEN