0%

Hexo blog 迁移

换电脑的折腾之一。真够麻烦的……

下载软件

nodejs
git
npm可能也需要更新(npm update)

拷贝源文件

必须的有:
scaffolds/(文章模版)
source/(所有文章和page)
themes/(主题文件夹)
.gitignore(忽略的文件和文件夹)
_config.yml(站点配置文件)
package.json(依赖包的名称和版本号)
介于我设置了robots,所以也要一并拷到新电脑上。
(试了下全拷直接覆盖会报错,还是拷以上必须的文件即可,后面再细说)

配置

nodejs

设置淘宝源:

1
npm config set registry https://registry.npm.taobao.org

还原官方源:

1
npm config set registry https://registry.npmjs.org/

确认源:

1
npm config get registry

git

1、配置GitHub的用户名与邮箱:

1
2
git config --global user.name "yourname"
git config --global user.email "youremail"

2、查看config确认是否配置成功:

1
git config --list

3、创建密钥:

1
2
ssh-keygen -t rsa -C "your_email@youremail.com"
# 过程可以直接全部默认回车,如需密码的话输入密码

4、获取密钥:

1
cat ~/.ssh/id_rsa.pub

5、成功获取密钥后在github的个人设置里添加SSH

6、验证是否成功:

1
ssh -T git@github.com

安装Hexo及各种插件

1、任意目录运行:

1
npm install hexo-cli -g

2、建一个空的blog目录运行(先不要在拷过来的文件上操作):

1
hexo init

3、成功后再:

1
npm install

4、hexo s 一下确认能否正常运行,正常的话就退出然后把拷的文件覆盖过来

5、覆盖完后:

1
2
3
npm install hexo-deployer-git --save
hexo g
hexo d

运行完后 hexo s 看看是否报错。

6、正常的话就可以安装以前装过的插件:

1
npm install 插件名 --save

我以前装过的:

hexo-generator-searchdb
hexo-symbols-count-time
hexo-abbrlink
hexo-blog-encrypt
hexo-asset-image
hexo-generator-indexed
hexo-reference
hexo-bilibili-bangumi
hexo-generator-feed
hexo-generator-archive / hexo-generator-tag / hexo-generator-category

7、安装完后 hexo clean 一下再 hexo g & hexo d,blog应该就能正常运行了。