Deploy Jekyll to GitHub Pages with Travis CI
If you want to use GitHub Pages with custom Jekyll plugins (e.g. anything other than officially supported plugins) — you need to generate the site content and push it to the repository manually. If you want to automate this step and deploy your site every time you push changes to Jekyll, Travis CI might help you.
Travis CI is a continuous integration tool which allows you to setup build process for your GitHub repo. It is free for public repos. Every time you push changes to the repository, Travis CI will setup a virtual machine and run the build script you provide it.
Since Jekyll runs on Ruby, we need to tell Travis to setup a VM with Ruby environment.
We need to create
.travis.yml file in the root of the repository for that.
To deploy our Jekyll site we need to push generated static content to
gh-pages branch of our repository.
To achieve this we need to do following:
- clone our repo at
gh-pagesbranch with write permissions to
- build Jekyll site to
- commit and push all changes in
We need to create personal access token and set it in Travis build “Environment Variables” settings to be able to clone the repo with write permissions.
Then we need to add following Bash script to
script/cibuild in our repository:
After this is done, Travis will run the build script after every push to
master branch and deploy
the generated static content to
gh-pages branch automatically!