0%

hexo同步到github

本文介绍hexo如何与github结合打造个人博客,其中涉及github、hexo的相关配置。分享给大家共同学习、交流。

演示地址

hexo相关配置

修改配置文件中deploy

  • 版本3.0一下

    1
    2
    3
    4
    deploy: 
    type: github
    repository: git@github.com:your-github/your-github.github.io.git
    branch: master
  • 版本3.0以及之上

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

安装 hexo-deployer

1
$ npm install hexo-deployer-git --save

Github相关设置

  • 注册github账号(自行百度搜索)

  • 设置ssh

    1
    2
    3
    git config --global user.name "your-github"
    git config --global user.email "your-github@xx.com"
    ssh-keygen -t rsa -C "xxx@xx.com"
  • github上配置秘钥

找到c盘.ssh文件夹下的id_rsa.pub,将文件内容拷贝到github中的setting的ssh下面

同步文件到github

  • 生成静态文件并发布
1
2
3
4
$ hexo generate
$ hexo deploy
// or
$ hexo deploy -m '提交信息'