Hexo allows you to deploy your blog to github pages or any other git repository pretty much out of the box.

Your hexo can be hosted for free on github pages but this tutorial would also work for any other git hosting site.


There is a plugin developed by the hexo team that will help do just that, deploy to git in one command.

1) Installation

While at the root of your hexo project:

npm install hexo-deployer-git --save

2) Configuration

Open your _config.yml and edit the Deployment section:

type: git
repo: https://github.com/username/your-blog-url.github.io

Use your blog github repo URL in the repo property

3) Deploy !

Run hexo deploy and your blog is online. Easy, wasn’t it ?


You need to generate your site first

hexo deploy will not generate your pages, you need to launch hexo generate first.

If you want an easy way to do both at the same time, you could create an npm script to do this:

In your package.json add

"scripts": {
"deploy": "hexo generate && hexo deploy"

then run npm run deploy to first generate and then deploy your blog.

You can add several repos if you want to push your blog to several places

Just duplicated the repo: line:

type: git
repo: https://github.com/username/your-blog-url.github.io
repo: https://github.com/username/your-second-blog-url.github.io

You can personalize the git commit message

By default the message will be: Site updated: {{ now(“YYYY-MM-DD HH:mm:ss”) {{

You can add a message property if you want to use your own:

type: git
repo: https://github.com/username/your-blog-url.github.io
message: New post added

You can use SWIG templates in the message although I am not sure how that would help. The now method in the default message is a custom swig helper as you can see in the source.