最近重装了windows系统,因此需要重新部署hexo博客,记录下重新部署的步骤
安装Node.js#
- 下载
- 下载稳定版 nodejs
- 我这里给的是64位的,选中安装路径后就一直点Next。
- 设置环境变量
- 右键"此电脑"-"属性"-"高级系统设置"-"环境变量"-选中用户变量的Path编辑-"新增"将nodejs按照路径加入
- 我的安装路径是 D:
- 验证
- 按Win+R打开命令提示符,输入node -v和npm -v,出现版本号就成功了
安装Git#
为了把本地的文件上传到github上,我们需要用到分布式版本控制工具————Git
下载地址Git
- 验证
- 按Win+R打开命令提示符,输入git --version验证是否安装成功。
Github加入密钥#
设置git用户名和email
1
2git config --global user.name "sysuleo"
git config --global user.email "youremail@xx.com"生成密钥
1
ssh-keygen -t rsa -C "youremail@xx.com"
保存密钥到github 打开github,在头像下面点击settings,再点击SSH and GPG keys,新建一个SSH,将如下内容复制进去
1 | cat ~/.ssh/id_rsa.pub |
拉去hexo 个人博客源码#
新建blog目录, 如 D:_blog
1 | cd D:\github\sysuleo_blog |
安装Hexo#
安装hexo: cd到博客目录下, 输入
1
npm install hexo-cli -g
npm卡顿时可以换源
1
npm config set registry http://registry.npmmirror.com
验证: 输入
1
hexo -v
删掉原blog文件夹部分文件#
只需保留_config.yml,theme/,source/,scaffolds/,package.json,.gitignore 这些项目, 删除其余文件
安装依赖文件#
1 | npm install |
安装部署插件#
1 | npm install hexo-deployer-git --save |
最后验证是否成成功
1
hexo clean && hexo g && hexo s
问题汇总#
1. pandoc exited with code null报错#
执行hexo-g 时报错如下
1
2
3
4
5
6
7
8
9
10...
INFO Start processing
ERROR {
err: Error:
[ERROR][hexo-renderer-pandoc] On D:\github\sysuleo_blog\sysuleo.github.io_resource\themes\hexo-theme-next\languages\README.md
[ERROR][hexo-renderer-pandoc] pandoc exited with code null.
at Hexo.pandocRenderer (D:\github\sysuleo_blog\sysuleo.github.io_resource\node_modules\hexo-renderer-pandoc\index.js:114:11)
at Hexo.tryCatcher (D:\github\sysuleo_blog\sysuleo.github.io_resource\node_modules\bluebird\js\release\util.js:16:23)
at Hexo.<anonymous> (D:\github\sysuleo_blog\sysuleo.github.io_resource\node_modules\bluebird\js\release\method.js:15:34)
...
下载安装 pandoc,重新启动命令行就ok了
2. tomorrow-night.css缺失#
1 | ... |
参考官网Troubleshooting: If you get an error like Error: ENOENT: no such file or directory it’s probably due to to mixing uppercase and lowercase letters in your tags, categories, or filenames. Git cannot automatically merge this change so it breaks the automatic branching.
最后没找到问题, 重新部署解决了...
3. git pull报错Host key verification failed.#
1 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
参考We
updated our RSA SSH host key, 重新生成known_host文件
1
$ ssh-keygen -R github.com
4. git报错"You're using an RSA key with SHA-1, which is no longer allowed.#
参考Eclipse/Git: "You're using an RSA key with SHA-1, which is no longer allowed":
According to Github security blog RSA keys with SHA-1 are no longer accepted.
Use the following command to create new SSH key with ECDSAencryption and add it to Github:
ssh-keygen -t ecdsa -b 521 -C "your_email@example.com"
5. git clone 失败"Failed to connect to github.com port 443 after 21106 ms: Could not connect to server"#
- 本地使用了vpn科学上网,需要设置代理端口(因人而异,参考【经验宝宝】Failed to connect to github.com port 443: Operation timed out)
1 | git config --global http.proxy http://127.0.0.1:7890 |
6. npm install报错#
更换淘宝镜像时,发现报错证书已过期,那是因为淘宝的镜像网站更换了,原地址已不再维护但是仍然可访问。具体公告在:developer.aliyun.com/mirror/NPM, 具体变化如下:
1 | npm config set registry http://registry.npmmirror.com |