hexo部署github pages

注册github

这里不多做解释,附上github地址:github

创建github page 仓库

建个github库。名字必须是 yourname.github.io

yourname 就是你的github的用户名 例如:zhouyajun.github.io

在本机生成ssh key
1
2
ssh-keygen -t rsa -C "你的邮箱地址"
一路回车 enter

生成的key一般位于C:\Users\Administrator.ssh文件夹中

找到.id_rsa.pub文件,打开,并复制其中内容

登录github,找到setting->ssh GPG keys页面,添加sshkey

添加ssh_key界面

用你刚刚复制的is_rsa.pub里面的内容复制到github add ssh key页面中

添加ssh_key界面

至此,ssh秘钥配置完成

配置hexo项目中的自动部署

打开 _config.yml文件 ,找到并修改如下代码

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

注:type:HEXO更新到3.0之后,deploy的type 的github需要改成git

必须事先安装hexo-deplorer-git扩展,否则会报 ERROR Deployer not found: git 的错误

1
npm install hexo-deployer-git --save

配置完成

执行部署
1
2
3
hexo clean
hexo g
hexo deploy