Github和Hexo操作文档

Github搜索指南

  1. 搜百科大全,搜索优秀的资源。xxx awesome

  2. 找例子 xxx simple

  3. 找空项目架子 xxx starter

  4. 找技术教程 django tutorial


Hexo

1.Hexo部署Github

建立密钥通信

打开.ssh使用 ssh-keygen 生成密钥,然后一直回车

1
2
3
cd ~/.ssh

ssh-keygen -t rsa -C "your_email@example.com"

密钥生成成功

1
2
3
4
Your identification has been saved in /home/you/.ssh/id_rsa.
Your public key has been saved in /home/you/.ssh/id_rsa.pub.
The key fingerprint is:
…………………此处是密钥内容…………………… your_email@example.com

在 chengjianhua.github.io 的首页菜单栏中点击 Settings –> Deploy keys –> Add deploy key,然后将生成的 id_rsa.pub 中的内容全选(全部)复制到 key 输入框中,然后点击 Add key 完成添加公钥。

1
cat id_rsa.pub

检查配置是否成功

1
ssh -T git@github.com

如果出现以下内容即表示配置完成并且成功!

1
2
3

Hi username! You've successfully authenticated, but GitHub does not
provide shell access.

hexo 的配置文件 config.yml 中的 deploy 属性。

1
2
3
4
deploy:
type: git
repo: git@github.com:username/username.github.io.git
branch: master

错误:fatal: unable to access

fatal: unable to access ‘https://github.com/blog20170623/blog20170623.github.io/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

这个问题就是SSH Key需要重新更新了。就是上面可以解决这个的问题

出现了这个错误之后,百度谷歌之后,有很多文章描述这种错误的,其他方法我并没有试一试,写的并不清楚,我只找到我能够看得懂试,发现完全有用。

2.Hexo常用插件

Hexo 提供了快速方便的一键部署功能,让您只需一条命令就能将网站部署到服务器上。需要插件deployer-git

1
2
3
hexo deploy

npm install hexo-deployer-git --save

文章置顶

hexo-generator-index是官方默认的博客文章排序插件,在我们安装hexo时就存在该插件了,hexo博客正常运行离不开该插件。该插件实现了按文章发表时间倒序排序,没有实现文件置顶功能。

hexo-generator-index-pin-top是一个文章置顶功能插件,在置顶之外实现文章按发表时间倒序功能,该插件用于替换hexo-generator-index插件

1
2
npm install hexo-generator-index-pin-top –save
npm uninstall hexo-generator-index –save

添加 RSS 订阅支持

1
npm install hexo-generator-feed --save

在 Hexo 根目录下的 _config.yml 文件中,新增以下的配置项:

1
2
3
4
5
6
7
8
9
feed:
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: ' '
order_by: -date

Hexo deploy部署Spawn failed错误

Error: Spawn failed 问题大多是因为git进行push或者hexo d的时候改变了一些.deploy_git文件下的内容

1
2
3
4
5
6
7
8
9
10
11
12
13
remote: Resolving deltas: 100% (1013/1013), completed with 115 local objects.
remote: error: Trace: 65175cban911053cf6232469de71dc52c05baaaae7f071bc4d
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File images/Video/light hunter By An9Angel.mp4 is 134.31 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To github.com:username/username.github.io.git
! [remote rejected] HEAD -> gh-pages (pre-receive hook declined)
error: failed to push some refs to 'github.com:username/blog20170623.github.io.git'
FATAL {
err: Error: Spawn failed
at ChildProcess.<anonymous> (/Users/username/Hexo/blog/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (node:events:520:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) {

解决办法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
cd /hexo/blog/

ls -al # 显示出所以文件包括隐藏目录.deploy_git

rm -rf .deploy_git/ #删除git提交内容文件夹

## 执行

git config --global core.autocrlf false

## 最后

hexo c && g && d

jul-853