拷贝源文件

我比较懒 不搞那些花里胡哨 直接打包博客源文件到新电脑

只需要打包下面这几个文件(我是顺手全打包了)

1
2
3
4
5
6
将下面的文件或文件夹复制到新的博客目录下进行替换
_config.yml
package.json (这个没有用到)
scaffolds/ (这个没有用到)
source/
themes/

环境部署

在新电脑上安装 nodejsGit

安装完了之后 新建一个目录把博客文件解压到文件夹 打开 Git bash

1
2
$ git config --global user.name "username"
$ git config --global user.email "username@example.com"

然后切换到用户主目录

1
$ ssh-keygen -t rsa -C “youremail@example.com”

输入邮件地址一路回车 完成会在 .ssh 目录下生成 SSH 密钥

输入 cat ~/.ssh/id_rsa.pub 查看公钥 复制添加到Coding或者Github

接着切换到博客目录输入 npm install hexo-cli -g 安装hexo

然后直接

1
2
$ hexo g
$ hexo d

一些错误 (坑)

我之前博客是双线部署coding+GitHub 换电脑后只部署到coding 我开始是直接注释

1
2
3
4
5
6
deploy:
type: git
repo:
#Github:https://github.com/funny/funny.github.io.git
Coding:git@e.coding.net:funny/blog/blog.git
branch: master

然后就开始了 hexo d 的时候一直报错

Please make sure you have the correct access rights and the repository exists

在网上找了找都无法解决 后面我改成了

1
2
3
4
5
deploy:
type: git
repo: git@e.coding.net:funny/blog/blog.git
#Github:https://github.com/funny/funny.github.io.git
branch: master

成功解决

报错

The file will have its original line endings in your working directory

解决方法运行下面命令设置一下Git终端禁用自动转换功能就行

1
$ git config --global core.autocrlf  false

我就遇到了这些问题 以后遇到再更新吧