Sign inSign up

uoks/nb_to_web

By uoks

•Updated almost 8 years ago

Convert jupyter notebooks to a blog like website

Image
1

961

uoks/nb_to_web repository overview

⁠NB To Web

Convert your juypter notebooks to a website

⁠ScreenShot

screenshot

⁠docker volume

volume pathisRequireddescription
/opt/notebook/contentYesthe notebooks and static resources from jupiter
/opt/notebook/outputNothe generated html/css/js from content
/opt/notebook/config.pyNothe custom config for pelican

⁠docker env config

Namedefault valuedescription
SITENAMENB to Webthe name of the site
SITEURLbase url of the site
AUTHORMing Wanthe author fof the site
TIMEZONEUTCtime zone for pelican
DEFAULT_LANGendefault lang for pelican
DEFAULT_PAGINATIONFalsedefault page nation for pelican
CATEGORIES_CUSTOM_ORDERthe custom order for pelican-category-custom-order plugins. split with ,, e.g. Get Start, Demo
STATIC_PATHSthe static path in the content, split with ,, e.g. img, vedio

you can use /opt/notebook/config.py to set more settings for pelican⁠.

⁠How to use

suppose you have some ipynb like

-- notebooks
 +-- img
   +-- demo.png
 +-- getstart_1.ipynb
 +-- getstart_2.ipynb
 +-- demo_1.ipynb
 +-- demo_2.ipynb

⁠Set meta data for your ipynb

⁠Option 1: Separate MD metadata file

Place the .ipynb file in the content folder and create a new file with the same name as the ipython notebook with extension .nbdata. For example if you have my_post.ipynb create a my_post.nbdata.

The .nbdata should contain the metadata like a regular Markdown based article:

Title:
Slug:
Date:
Category:
Tags:
Author:
Summary:

Note the empty line at the end, you need that.

You can also specify to only include a subset of notebook cells with the Subcells metadata item. It should contain the index (starting at 0) of first and last cell to include (use None for "unlimited"). For example, to skip the first two cells:

Subcells: [2, None]
⁠Option 2: Metadata cell in notebook

With this option, the metadata is extracted from the first cell of the notebook (which should be a Markdown cell), this cell is then ignored on the rendering of the notebook. This avoid the burden of maintaining a separate file or manually editing the json in the .ipynb file like the previous options.

you can put the metadata in the first notebook cell in Markdown mode, like this:

- title: My notebook
- author: John Doe
- date: 2018-05-11
- category: pyhton
- tags: pip

read more for pelican-ipynb⁠

⁠Run Service with docker

docker run -v $(pwd)/notebooks:/opt/notebook/content -e SITENAME=mysite \
           -e CATEGORIES_CUSTOM_ORDER=GetStart,Demo \
           -e STATIC_PATHS=img \
           -p 8000:8000 \
           uoks/nb_to_web

The you can access http://localhost:8000⁠ to get the web site

⁠Generate static website with docker

If you just want to generate the static website, you can run

docker run -v $(pwd)/notebooks:/opt/notebook/content \
           -v $(pwd)/output:/opt/notebook/output \
           -e SITENAME=mysite \
           -e CATEGORIES_CUSTOM_ORDER=GetStart,Demo \
           -e STATIC_PATHS=img \
           uoks/nb_to_web make html

Then push the output/ to anywhere, e.g. gitpage

⁠Power by

Tag summary

Content type

Image

Digest

Size

386.3 MB

Last updated

almost 8 years ago

docker pull uoks/nb_to_web