Travis CI + Hexo Automatically Deploy
Hexo is a powerful blog engine. It is a good choice for a personal blog. I have used it for 5 years. Recently, I setup my English site besides the original Chinese site. With 2 sites, it is more work to write, git and deploy.
Fortunately, there is a better solution for this problem. We could use Travis CI to automatically deploy the blog. The remain work is writing posts and git commit and push them. The CI would help us to deploy sites automatically.
How to configure that?
Sign up for Travis CI using Github account.
With Github education package, you could have the benefit to private builds for free while you’re a student. But it is only an optional choice, you can still use Travis CI without it.
Give Travis CI the permission to access your Github repositories.
In Personal access tokens, generate a token for Travis CI with repo
scopes. Copy the token.
In Travis CI repositories page, select your Hexo repo and click on Settings. In Environment Variables section, Add a new variable with NAME is GH_TOKEN
, VALUE is the token you copied in the last step.
Create a file named .travis.yml
in your Hexo repo. Refer to following content and change the value as your situation. I added some comments for help.
1 | os: linux |
Once you push the .travis.yml
file to your repo, you can see the build status in Travis CI. Once it complete, check your site repo and access your blog to see the update.