Deploying Nikola to GitHub

Alright, so this new shiny blog is running nicely on our development machine, but we'd like to share it with the rest of the world. For now, let's go with Github Pages.

Create a personal Github Pages Repository

From the Github Page, create repository with the following name: <Your Github Username>.github.io

Initialize a git repository in your Nikola source directory

Now go to your Nikola source directory and run the following commands.

$ git init .
$ git remote add origin git@github.com:<Your Github Username>/<Your Github
Username>.github.io.git

Setup branches and remotes in conf.py

For a github user page (user.github.io), the default settings should be good to go, but have a look at the following items in conf.py.

  • GITHUB_DEPLOY_BRANCH
  • GITHUB_SOURCE_BRANCH
  • GITHUB_REMOTE_NAME
  • GITHUB_COMMIT_SOURCE

Create a .gitignore file

Add at least the following entries.

cache
.doit.db
__pycache__
output

And finally, deploy

Run nikola github_deploy. This should build the site, commit the output folder to the deploy branche, and push to GitHub. Your website should be up and running very soon.