hexo从Windows移到Deepin

电脑换系统了,所以hexo环境又要重新搭建,这次使用的是deepin系统,作为国产linux里数一数二的linux发行版,使用体验还是可以的。

安装需要的软件:

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

Hexo :

1
sudo npm install hexo-cli -g

安装过程中如果遇到警告可以不用管

添加新密钥

查看密钥是否添加

1
2
3
4
5
6
7
ssh -T git@github.com

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

上传密钥

打开:github,登录,点击:头像 -> settings -> SSH and GPG keys
接着将以前的秘钥Delete删除
然后点击上方的New SSH key

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

1
2
ssh -T git@github.com
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 "邮箱"

安装相关模块

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 // 建立站点地图

如果出现警告,不用理会,影响不大。

测试

打开之前的hexo项目,新建一篇文章测试:

1
hexo new "test"

接着生成静态文件,开启服务

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

其他问题:

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

1
2
3
4
5
6
7
8
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

最后重新生成密钥并上传。

0%