Automating Nikola rebuilds with Travis CI

The github_deploy command included with Nikola is nice to have, but you need to have a working build environment to update your blog.

Wouldn't it be much more convenient if we could just write or update a post and see the changes automagically appear on our website? Using continuous integration, we can do just that.

Setting up Nikola

We need to make one important change to our


Without this change, Travis CI is going to get trapped in an infinite loop.

Setting up Travis CI

First, let's install ruby and gem if we don't have them.

Next, let's get travis.yml from and save it as .travis.yml Then, update these lines

git config --global 'Your Username'
git config --global 'Your email'
git remote add origin

If you want extra languages, add the correct packages under the following section.

    - language-pack-en-base

Next, let's generate a SSH key for Travis CI

echo id_rsa >> .gitignore
echo >> .gitignore
ssh-keygen -C TravisCI -f id_rsa -N ''

Copy the contents of and add them to Github -> Your Page Repository -> Settings -> Deploy keys. Make sure, Allow write access is checked.

Playing nice with Ruby

Install the travis gem.

gem install --user-install travis

We can now use the Travis CI command-line client to log in, enable the repository, and encrypt our SSH key.

$ travis login

We need your GitHub login to identify you.
This information will not be sent to Travis CI, only to
The password will not be displayed.

Try running with --github-token or --auto if you don't want to enter your password anyway.

Username: MyUsername
Password for MyUsername: ********************************************************
Successfully logged in as MyUsername!

$ travis enable

Detected repository as MyUsername/, is this correct? |yes| yes
MyUsername/ enabled :)

$ travis encrypt-file id_rsa --add

encrypting id_rsa for MyUsername/
storing result as id_rsa.enc
storing secure env variables for decryption

Make sure to add id_rsa.enc to the git repository.
Make sure not to add id_rsa to the git repository.
Commit all changes to your .travis.yml.

Finally, commit everything to GitHub.

$ git add .
$ git commit -am "Automate builds with Travis CI"
$ git push

Watch Travis CI do its job

After a couple of minutes, your site should be good to go.

Check the status of your builds at