I think that many people write blogs with Markdown, but I think that there are times when you want to post a notebook created with Jupyter Notebook to the blog as it is.
Let's do this with the static site generator Pelican and its plugin pelican-ipynb.
I think it is better to create an environment on virtualenv.
$ pip install jupyter
$ pip install pytz
$ pip install Markdown pelican
This time, create a directory called my_project for testing.
$ mkdir my_project
$ cd my_project/
$ pelican-quickstart
For quickstart, I referred to here. Please replace the title, author, and other settings with your own.
> Where do you want to create your new web site? [.]
> What will be the title of this web site? my project
> Who will be the author of this web site? patraqushe
> What will be the default language of this web site? [en] ja
> Do you want to specify a URL prefix? e.g., http://example.com (Y/n) n
> Do you want to enable article pagination? (Y/n) n
> What is your time zone? [Europe/Paris] Asia/Tokyo
> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n) y
> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n) y
> Do you want to upload your website using FTP? (y/N) n
> Do you want to upload your website using SSH? (y/N) n
> Do you want to upload your website using Dropbox? (y/N) n
> Do you want to upload your website using S3? (y/N) n
> Do you want to upload your website using Rackspace Cloud Files? (y/N) n
> Do you want to upload your website using GitHub Pages? (y/N) n
Done. Your new project is available at /home/driller/pelican/my_project
In the my_project directory
$ mkdir plugins
$ git clone https://github.com/danielfrg/pelican-ipynb.git plugins/ipynb
$ vi pelicanconf.py
Add the following to pelicanconf.py
MARKUP = ('md', 'ipynb')
PLUGIN_PATH = './plugins'
PLUGINS = ['ipynb']
This time, prepare a directory for .ipynb files in the content directory. It can be directly under the content directory.
In the my_project directory
$ cd content/
$ mkdir notebook
Place the .ipynb file created by jupyter notebook in the my_project / content / notebook directory.
Then create a file called
$ cd notebook/
$ ls
test01.ipynb
$ vi test01.ipynb-meta
Contents of test01.ipynb-meta
Title: notebook test
Slug: test01
Date: 2015-12-18 0:00
Category: Pelican
Tags: Python, Pelican, Jupyter
Author: patraqushe
Summary: jupyter notebook article
Go back to the my_project directory, build your site with make html, and start the server with make serve.
$ ls
test01.ipynb test01.ipynb-meta
$ cd ../..
$ make html
$ make serve
If you access http: // localhost: 8000
with a browser, you will see a screen like this.
After that, change the theme and settings in various ways and adjust them to your liking.
Recommended Posts