Automated publishing of Jekyll sites on GitHub


Publishing a Jekyll based static website on GitHub Pages is quite easy once it is setup properly. This way you can trigger a publish on a different branch every time a change is pushed into the GitHub repository.

I will describe how to do it using rake-jekyll. For more detailed and probably updated information, please refer to the rake-jekyll documentation on the project page

If you already don’t have one, create a Gemfile in your repository or update one you already have according to the following:

source ''

gem 'jekyll'
gem 'rake'
gem 'rake-jekyll'

Create or edit file Rakefile in your repository:

require 'rake-jekyll'

Create file .travis.yml in your repository:

language: ruby
sudo: false
rvm: 2.2.0
script: bundle exec rake deploy

Install travis gem using shell:

$ gem install travis

Enable Travis CI for your github repository:

  • if you already don’t have a Travis CI account, sign up for one.
  • open your profile page on Travis
  • find your github repository for the website and turn on the switch the switch
  • click on the repository settings repository settings
  • enable the setting “Build only if .travis.yml is present.” enable setting

Generate a new personal access token on GitHub:

  • Generate a new personal access token for your Github profile
  • select public_repo scope, enter description and generate. You will need the token displayed on the page for the next step.

Encrypt the token using the following shell command (replace the <token> part with your generated token from the previous step):

$ travis encrypt GH_TOKEN=<token> --add

Following content will be added to your .travis.yml file:


Commit your changes and push to GitHub. Travis will trigger a build and publish your website in a couple of minutes.

comments powered by Disqus