0%

[hexo]重装系统后重新部署hexo

最近重装了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
    2
    git 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
2
3
cd D:\github\sysuleo_blog

git clone xxxxxx # 拉去博客源码

安装Hexo#

  • 安装hexo: cd到博客目录下, 输入

    1
    npm install hexo-cli -g

  • npm卡顿时可以换源

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

  • 验证: 输入

    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 exited with code null 的解决方案

下载安装 pandoc,重新启动命令行就ok了

2. tomorrow-night.css缺失#

1
2
3
4
5
6
...
INFO Start processing
FATAL {
err: Error: ENOENT: no such file or directory, open 'D:\github\sysuleo_blog\sysuleo.github.io_resource\node_modules\highlight.js/styles/tomorrow-night.css'
at Object.openSync (node:fs:600:3)
...

参考官网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
2
3
4
5
6
7
8
9
10
11
12
13
14
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
.........
Please contact your system administrator.
Add correct host key in /c/Users/liuwen03/.ssh/known_hosts to get rid of this message.
Offending RSA key in /c/Users/liuwen03/.ssh/known_hosts:1
RSA host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

参考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"