github博客换机无缝迁移教程

迁移参考(这个迁移教程是不全的):

https://blog.csdn.net/qq_43698421/article/details/120407042?fromshare=blogdetail&sharetype=blogdetail&sharerId=120407042&sharerefer=PC&sharesource=a1150568956&sharefrom=from_link

搭建参考:

https://yangcheneee.github.io/categories/博客/

旧电脑如下操作:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
## 旧电脑如下操作:
bash
git clone $原仓库
cd到目录下
git checkout -b hexo
git push origin hexo:hexo
## 在hexo分支删掉除了.git文件之外的其他文件 将原来main分支的下面六个东西复制到下来:
_config.yml
package.json
scaffolds/
source/
themes/
.gitignore
## 接着
git add .
git commit -m '提交仓库所需资源'
git push origin hexo:hexo

同时,假如安装了butterfly主题或其他主题,注意保留其下的_config.yml,之后会用到。 同时注意在main分支的public目录下的资源(图片),如果后续发现没有这些东西,也要手动迁移一发到新电脑上。

新电脑如下操作:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
git clone $原仓库
cd到目录下
git checkout hexo
npm install hexo-cli -g
npm install
## 假如用的是butterfly主题
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
## 安装依赖
npm install hexo-renderer-pug hexo-renderer-stylus --save
npm install hexo-generator-search --save
## 同时记得替换/theme/butterfly 下的_config.yml(旧电脑上的迁移过来)
hexo g
hexo s
## 注意如果这里发现图片不对劲,可能是public下面的图片没有迁移过来,从旧电脑上完全迁移下来即可