After setting up build automation we also wanted it not to happen only when updating the documentation repository.

Besides hosting documentation, Elegant website also serves as a live demo of the current release. This meant, the website should be regenerated and updated every time when a documented is added or edited, and also when Elegant theme is updated.

Github and Travis doesn’t offer dependent builds out of the box, so the trick goes to ‘signal’ via a github token to trigger a Travis-CI build.

The technical solution

The approach goes via tweaking the ’test validation’ .travis.yaml and adding some more steps:

The initial file (similar to the one in our previous article, but for running the ‘page build’ with latest repo checkout) looks like:

# Copyright (C) 2017, 2018 Pablo Iranzo Gómez <[email protected]>

language: python
dist: trusty
sudo: required

  - "3.5"

# prepare and move data for execution

  - pip install -U pip
  - pip install -U setuptools
  - pip install -r tests/requirements.txt
  - pip install -r tests/test-requirements.txt
  - pip install peru
  - mkdir -p tests/themes/elegant
  - mv templates tests/themes/elegant/
  - mv static tests/themes/elegant/
  - cd tests && peru sync

  - pelican content/ -o output/

Is then modified to add:

  - npm install travis-ci

  - node trigger-build.js

This installs Travis-CI utilities and runs a custom script ’trigger-build.js’ with node, which in turn actually triggers Travis build.

The script, downloaded from Kamran Ayub blog has been edited to specify the ‘repo’ we will trigger and the name of the environment variable containing the token:


var Travis = require('travis-ci');

// change this
var repo = "Pelican-Elegant/documentation";

var travis = new Travis({
	version: '2.0.0'


	// available through Travis CI
	// see:
	github_token: process.env.TRATOKEN

}, function (err, res) {
	if (err) {
		return console.error(err);

	travis.repos(repo.split('/')[0], repo.split('/')[1]).builds.get(function (err, res) {
		if (err) {
			return console.error(err);
			build_id: res.builds[0].id
		}, function (err, res) {
			if (err) {
				return console.error(err);

As you can see, in line 14, it grabs the github token from environment variable TRATOKEN that we’ve defined in Travis-CI environment for the build.

This is similar to what we did in the documentation repo to push the built website to another repo.

With this solution in place, when a new commit is merged on ‘master’ branch on the ’theme’ repo (elegant), Travis does get invoked to schedule a build on the documentation repo, thus, rendering the live website with latest templates.

Enjoy! (and if you do, you can Buy Me a Coffee )