0%

Deploy Hexo to Github With Token

Hexo provides a fast and easy deployment strategy. You only need one single command to deploy your site to your server.

1
hexo deploy

To deploy Hexo to Github, you need to install the necessary plugin(s), hexo-deployer-git that is compatible with the deployment method provided by your server/repository. Deployment is usually configured through _config.yml. A valid configuration must have the type field. For example:

1
2
deploy:
type: git

At the beginning, you need to go to this website to see how to create a GitHub Personal Access Token. Once the token is generated, keep it somewhere for later use.

Go to Hexo file _config.yml, and include below code block in it. Set the token parameter to be the Github token name which was just generated.

1
2
3
4
5
6
7
8
9
deploy:
type: git
repo:
github:
url: https://github.com/<myusername>/<myrepo>.git
branch: <branch_name>
token: $<token_name>
name: <my_visible_name>
email: <my_email>

After this, you could deploy Hexo to your Github repository. The command should be like this:

1
<token_name>=<token_value> hexo deploy;