该博客用于记录如何快速恢复博客环境

配置node

安装node环境

https://nodejs.cn/download/

安装最新版node,解压后配置环境变量,进入node的bin目录后链接npm和node到/usr/local/bin

1
2
ln -s $(pwd)/node /usr/local/bin/node
ln -s $(pwd)/npm /usr/local/bin/npm

然后配置lib/node_modules到环境变量,node -g安装的应用会安装到这里

1
2
echo "export \"PATH=\$PATH:$(pwd)\"" >> ~/.bashrc
source ~/.bashrc

如果没有梯子可以安装一下cnpm

1
npm install -g cnpm -registry=https://registry.npm.taobao.org

配置Github SSH

非常简单,本地生成公钥私钥之后将公钥放在Github SSH中即可

1
ssh-keygen -t rsa -C "xxx@xxx.com"

然后找到id_rsa.pub放到Github的ssh配置中

image-20250309112054425

配置PicGo

安装PicGo

1
npm install -g picgo

配置阿里云图床,在~/.picgo/config.json里填入对应信息就可,华东一填入oss-cn-hangzhou

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"picBed": {
"uploader": "aliyun",
"current": "aliyun",
"aliyun": {
"accessKeyId": "",
"accessKeySecret": "",
"bucket": "",
"area": "oss-cn-hangzhou",
"path": "",
"customUrl": "",
"options": ""
}
},
"picgoPlugins": {}
}

修改插入图片时上传图片,设置上传服务PicGo-Core,这里typora可能会报错找不到PicGo-Core,我们根据报错将PicGo链接到目标目录即可

image-20250309111834795

安装hexo

1
npm install -g hexo-cli

我们从github仓库中下载之前的blog,获取main分支

1
git clone -b main https://github.com/jking412/jking412.github.io.git

image-20250309112249369

进入文件夹

1
2
3
4
5
6
7
cd jking412.github.io
rm package-lock.json #这是一个不该上传的文件
npm install
cp -r butterfly themes
hexo clean
hexo g
hexo s

即可配置好本地hexo环境