Using Jupyter Notebooks in Nikola

When I tried to first import a Jupyter (ipython) file into Nikola it failed, I was quite disappointed because it was supposed to work out of the box.

But after a little research I found out if you use the nikola new_post with the --format=ipynb option it works perfectly

Original ipython file:

~/sites/website/trapezoid.ipynb
66590  9 Jun 04:59 trapezoid.ipynb

I ran the command: nikola new_post --title="IPython Notebook Demo" --format=ipynb --import=trapezoid.ipynb

Importing Existing Post
-----------------------
Title: IPython Notebook Demo
Scanning posts..........done!
[2016-06-09T18:20:46Z] INFO: new_post: Your post's text is at: posts/ipython-notebook-demo.ipynb

It produced the following slightly large file:

~/sites/website/posts/ipython-notebook-demo.ipynb
66815 10 Jun 04:20 ipython-notebook-demo.ipynb

This works beautifully. All it seems to do is append 10 lines to the metadata section of the jupyter notebook.

  "nikola": {
    "category": "",
    "date": "2016-06-10 04:20:46 UTC+10:00",
    "description": "",
    "link": "",
    "slug": "ipython-notebook-demo",
    "tags": "",
    "title": "IPython Notebook Demo",
    "type": "text"
  }

As you can see this is a standard Nikola header block for a new post, but this time at the bottom, not the top of the file. Below is the full metadata block including the 10 lines added by nikola.

 "metadata": {
  "kernelspec": {
    "display_name": "Python 3",
    "language": "python",
    "name": "python3"
  },
  "language_info": {
    "codemirror_mode": {
     "name": "ipython",
     "version": 3
    },
    "file_extension": ".py",
    "mimetype": "text/x-python",
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
    "version": "3.5.0"
  },
  "nikola": {
    "category": "",
    "date": "2016-06-10 04:20:46 UTC+10:00",
    "description": "",
    "link": "",
    "slug": "ipython-notebook-demo",
    "tags": "",
    "title": "IPython Notebook Demo",
    "type": "text"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}