Blogging with Nikola + Ipython + Git(Hub)

After a lot of different attempts now it seems that I’m able to run a static blog with Python, Nikola and Git.

The information are taken from:


  • first of all install some prerequisites:

    sudo aptitude install python-virtualenv virtualenvwrapper libxml2-dev libxslt-dev
  • export the environment path adding this line to ~/.bashrc:

    export WORKON_HOME=~/Envs

    now the virtualenv are located in ~/Envs (you can choose another folder, of course)

  • then create a virtualenv for the blog:

    mkvirtualenv -p /usr/bin/python nblog
  • enter the virtualenv with workon nblog

  • run

    pip install nikola pyzmq tornado jinja2 requests sphinx markdown
  • from the folder that will be the blog parent folder run

    nikola init myblog
  • list the themes and install a theme containing “ipython” into it

    nikola install_theme -l to list all the available themes in Nikola
    nikola install_theme jinja-site-ipython 
  • modify your file adding the following lines to your post_pages:

    ("posts/*.ipynb", "posts", "post.tmpl", True), ("stories/*.ipynb", "stories", "story.tmpl", False),

    and make explicit to use the IPython theme:

    THEME = 'jinja-site-ipython'
  • choose some options in the configuration file (your name, your blog name, if to gzip the files, add the search box, the disqus comments, if to use teasers and so on)

  • to write a new post, just:

    nikola new_post -f ipynb

    or -f markdown to use the markdown syntax

  • then, nikola build to build the site and nikola serve to see it locally at localhost:8000


Now we want to deploy the blog on the blogging platform GitHub Pages. To do this you need a GitHub account.

  • create a repository named

  • install git locally and (if on Ubuntu 13.04) activate git subtree with

    sudo chmod +x /usr/share/doc/git/contrib/subtree/
    sudo ln -s /usr/share/doc/git/contrib/subtree/ /usr/lib/git-core/git-subtree

    if you are on an older Ubuntu version you can do this:

    git clone
    cd git-subtree
    sudo bash ./ 
    # all this does is copies a file to your git folder, i.e. /usr/lib/git-core
  • “git init” you blog with git init inside the main blog folder

  • set the remote origin locally with

    git remote add origin ssh://    

    I use ssh because I can log in without a password saving my key at

  • create an empty commit

    git commit --allow-empty -am "first commit"
  • now create the branch that will contain all the blog and move to it

    git branch AllBlog
    git checkout AllBlog
    git branch --set-upstream AllBlog origin/AllBlog

    the last passage is taken from here

  • add, commit and push the blog

    git add ./*
    git commit -am "first import"
    git push origin master
  • now you need to force the push of the files contained in the output folder to the master branch in order to make the blog visible

    git push origin `git subtree split --prefix output/ master`:master --force
  • once you have done you can configure nikola to deploy the blog automatically modifying the deploy option in

    DEPLOY_COMMANDS = ["git checkout AllBlog",
    				   "git add ./*",
    				   "git commit -a",
    				   "git push origin AllBlog",
    				   "git subtree push --prefix output/ origin master"]
  • now your workflow should be

    nikola new_post -f ipynb
    nikola build
    nikola serve # optionally to check the output locally
    nikola deploy

Google Authorship

It’s possible to let Google recognize and connect your contribution to the blog, that is, the posts will appear with your G+ profile photos and some information in the search results.


the only thing you need to do is to insert the line <a href="[profile_url]?rel=author">Google</a> in the index.html file, for example inserting it in the CONTENT_FOOTER = string, using your G+ profile link instead of [profile_url].

If you own a Google+ page you can also link your site using

EXTRA_HEAD_DATA = '<link href="<your page id>" rel="publisher" />'

key in the configuration file.
If you need some more html configuration you can add them there or you can copy the template folder from the parent theme folder to your theme and modify the template index.html.

See also

CNAME and personal domain

If you have a personal domain you can let github serve that domain. In brief, following this post you have to put in the output folder a file named CNAME containing your domain name and to create a DNS record on your domain host without

@ A

where is GitHub ip4 and A is the type of the record (address). You can also create a record for the www version of your domain resambling


and wait for the information to propagate (1 hour to 3 days).
Note that the output folder can be deleted so it’s better to create the CNAME file in the main or files directory and to copy or “rsync” it within the nikola deploy command workflow.

If you use Tophost and want both the www and the non-www version of your site available, follow this post.

More Reading
Newer// Nvidia drivers
comments powered by Disqus