更换电脑时转移hexo博客

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xjm850552586/article/details/84101308

本文适用对象:

  • 已成功搭建hexo博客,更换机器使用博客

(最近常用另外一个笔记本,于是便准备将hexo博客转移到该笔记本上来写,一些转移经验在本文分享)

一、前提条件

  • 安装git
  • 安装node.js
  • hexo个人博客
npm install hexo -g
npm install
npm --save install hexo-deployer-git
  • 设置Git的user name 和email
git config --global user.name 名字
git config --global user.email 邮箱
  • 输入如下指令,连续三个回车,生成密钥,最后得到了两个文件:id_rsa和id_rsa.pub(默认存储路径是:C:\Users\Ericam\.ssh)。
ssh-keygen -t rsa -C "你的邮箱"

打开id_rsa.pub文件复制全部内容。

进入github账户的setting界面,进入SSH and GPG Keys目录,删除原来的SSH,新建SSH

二、原文件拷贝

将原来电脑上的个人博客下的文件拷贝到新电脑中。

仅需拷贝如下文件及文件夹

——config.yml
package.json
scaffolds/
source/
themes/

此时输入如下指令

hexo clean
hexo g
hexo d

如果部署成功,则完成。

如果失败,可以继续查看本文,可能有解决方案。

三、其他问题

(一)输入hexo deploy命令没反应

config.yml文件中的deploy下的每行:后面都要有一个in英文半角空格。

同时type内容必须为git。

(二)Git提示error setting certificate verify locations

这是因为证书地址设置有误。

我采取了关闭证书校验的解决方法。

git config --system http.sslverify false

(三)部署时出现如下错误

Error: bash: /dev/tty: No such device or address error: failed to execute prompt script (exit code 1) fatal: could not read Username for ‘https://github.com’: No error

解决方案:

修改_config.yml文件如下:

deploy:
  type: git
  repository: ssh://[email protected]/用户名/用户名.github.io
  branch: master

猜你喜欢

转载自blog.csdn.net/xjm850552586/article/details/84101308