Correct Method to Deploy your Hexo Website onto Github Pages

After weeks of massing around with web platforms, I finally figured out the correct method to deploy my Hexo website onto Github Pages. It’s not hard and not complicated.

Prerequisites: you website, your github repo, a solid internet connection

The hexo document website has a detailed instruction about what you should prepare, so I’ll leave the job to them. After your website is finished with all impelmentations you want, run the following command:

$ npm install hexo-deployer-git -save

This plugin would generate the correct form for your deploy to Github Page. Then open _config.yml of your website and make the following edit:

# URL
url: https://username.github.io/

# Deployment
deploy:
  type: git
  repo: https://github.com/<username>/<reponame>.git
  branch: master

This would set up the link to your repo, so you don’t have to wake up Git(which makes a lot trouble if you use SSH connection on Windows).

Then you are one step before deployment. Simply run:

$ hexo clean
$ hexo generate
$ hexo deploy

to generate the correct website and push them into your repo. Then your website should be available on https://username.github.io/.

本作品采用 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议 (CC BY-NC-ND 4.0) 进行许可。