hexo从windows搬家到deepin

安装需要的软件

git 客户端:

1
sudo apt-get install git

node.js:

1
2
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential

npm:

1
sudo apt-get install -y npm

完成之后可以使用-v命令来查看是否安装成功

1
2
3
4
anjing@anjing-PC:~$ node -v
v6.3.1
anjing@anjing-PC:~$ npm -v
4.4.2

添加新秘钥

查看秘钥是否添加

1
2
3
4
5
6
anjing@anjing-PC:~$ ssh -T [email protected]
The authenticity of host 'github.com (13.229.188.59)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,13.229.188.59' (RSA) to the list of known hosts.
Permission denied (publickey).

看到提示Permission denied (publickey).
那就是秘钥有问题咯

创建秘钥

1
ssh-keygen -t rsa -C "你的邮箱地址"

接着敲3次回车,完成之后在/home/xxx/.ssh/下面可以看到秘钥

查看秘钥

1
cat /home/xxx/.ssh/id_rsa.pub

上传秘钥

点击:头像 -> settings -> SSH and GPG keys

Alt text
接着将以前的秘钥Delete删除
然后点击上方的New SSH key

Title处随便填写一个名字
Key 处将/home/xxx/.ssh/id_rsa.pub里面的内容复制到里面
接着点击Add SSH key

然后重新输入:

1
2
anjing@anjing-PC:~$ ssh -T [email protected]
Hi smelond! You've successfully authenticated, but GitHub does not provide shell access.

可以看到已经成功了

配置用户名和邮箱

1
2
3
git config --global user.name "用户名"

git config --global user.email "邮箱"

将源文件拷贝到目录

由于我的盘符没有全部分化为ext4格式,我留了40G的空间出来作为ntfs,所以我将我的文件拷贝到挂载的目录
/media/anjing/0007C530000C7583/blog,我已经将我的hexo里面的目录和文件移动到了这里
deepin会默认会自动挂载我ntfs格式的盘符
需要拷贝文件和目录有:

1
2
3
4
5
6
_config.yml
package.json
node_modules
scaffolds
source
themes

上面是hexo的核心文件

查看一下:

1
2
anjing@anjing-PC:/media/anjing/0007C530000C7583/blog$ ls
_config.yml node_modules package.json scaffolds source themes

可以看到我已经拷贝过来了

安装hexo

打开终端输入

1
npm install hexo-cli -g

结果提示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
/usr/lib
└─┬ [email protected]
....................省略
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/hexo-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! path /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/anjing/.npm/_logs/2018-06-21T12_07_44_418Z-debug.log

如果这里出现问题就使用sudo安装

1
sudo npm install hexo-cli -g

提示消息:

1
2
3
4
5
6
/usr/bin/hexo -> /usr/lib/node_modules/hexo-cli/bin/hexo
/usr/lib
└─┬ [email protected]
.....................省略
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/hexo-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

看到报错npm WARN 但是这里不要惊慌,出现WARN没什么问题,只要不出npm ERR!就行了

安装相关模块

1
2
3
4
5
npm install
npm install hexo-deployer-git --save // 文章部署到 git 的模块
(下面为选择安装)
npm install hexo-generator-feed --save // 建立 RSS 订阅
npm install hexo-generator-sitemap --save // 建立站点地图

安装上面的模块可能会出现下面错误,不用管即可

1
2
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

测试hexo

完成以后一定要在本地测试好

首先我们新建一片文章:

1
hexo new "test"

接着编辑一下:
Alt text

保存后部署本地发布

1
2
3
hexo clean  //清除缓存
hexo generate //生成静态文件
hexo server //本地启动服务

Alt text
可以看到在本地已经发布成功了

部署到github上

部署之前需要先修改hexo配置文件
打开_config.yml
找到

1
2
3
4
5
deploy:
type: git
# repo: https://github.com/smelond/smelond.github.io.git //将这个注释
repo: [email protected]:smelond/smelond.github.io.git //修改为这个
branch: master

如果不修改上面的内容可能部署会显示等其他错误:

1
2
Username for 'https://github.com': 
Password for 'https://[email protected]':

解决到上面的问题,就可以开始部署了

部署

1
2
3
hexo clean  //清除缓存
hexo generate //生成静态文件
hexo deploy //部署网站到设定的仓库

小小的提示:在hexo deploy 可能会卡5分钟左右

1
2
3
4
5
6
7
anjing@anjing-PC:/media/anjing/0007C530000C7583/blog$ hexo d
INFO Deploying: git
INFO Clearing .deploy_git folder...
INFO Copying files from public folder...
INFO Copying files from extend dirs...
[master fdb7ea5] Site updated: 2018-06-21 20:42:26
1 file changed, 1 insertion(+), 1 deletion(-) //在这个位置可能会卡主不动5分钟左右

等带几分钟后会提示:

1
2
3
To github.com:smelond/smelond.github.io.git
+ b66a43b...fdb7ea5 HEAD -> master (forced update)
分支 master 设置为跟踪来自 [email protected]:smelond/smelond.github.io.git 的远程分支 master。

提示上面的内容表示已经推送到github上了
接着打开博客看一下:
Alt text

其他问题:

如果部署网站到设定的仓库出现:

1
2
3
4
5
6
7
8
anjing@anjing-PC:/media/anjing/0007C530000C7583/blog$ hexo d
INFO Deploying: git
INFO Clearing .deploy_git folder...
INFO Copying files from public folder...
INFO Copying files from extend dirs...
[master 5de89e9] Site updated: 2018-06-21 20:31:16
1 file changed, 1 insertion(+), 1 deletion(-)
Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.

如果出现这条Warning就将/home/xxx/.ssh/下的id_rsa.pub 和 id_rsa删除

1
2
rm -rf /home/xxx/.ssh/id_rsa.pub
rm -rf /home/xxx/.ssh/id_rsa

然后重新创建上传秘钥即可





参考:
https://blog.csdn.net/lvonve/article/details/79587321
https://blog.csdn.net/Greenovia/article/details/60576985

本文标题:hexo从windows搬家到deepin

文章作者:smelond

发布时间:2018年06月21日 - 21:06

最后更新:2018年10月02日 - 22:10

原始链接:http://smelond.com/2018/06/21/hexo从windows搬家到deepin/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

分享