Package: pelican-jupyter
pelican-jupyter: Pelican plugin for Jupyter NotebooksInstallationpip install pelican-jupyterPelican and Jupyter versionsThe main focus is to run with the latest versions of the packages but there is a good chance the plugin will work correctly with older versions of Pelican and Jupyter/.
The recommended version of libraries are:pelican>=4notebook>=6nbconvert>=5UsageThis plugin provides two modes to use Jupyter notebooks inPelican:As a new markup language so.ipynbfiles are recognized as a valid filetype for an articleAs a liquid tag based on theliquid tags pluginso notebooks can be
included in a regular post using Markdown (.md) files.Mode A: Markup ModeOn yourpelicanconf.py:MARKUP=("md","ipynb")frompelican_jupyterimportmarkupasnb_markupPLUGINS=[nb_markup]IGNORE_FILES=[".ipynb_checkpoints"]With this mode you need to pass the MD metadata to the plugins with one of this two options:Option 1:.nbdatametadata filePlace the.ipynbfile in the content folder and create a new file with the
same name as the ipython notebook with extension.nbdata.
For example if you havemy_post.ipynbcreatemy_post.nbdata.The.nbdatashould contain the metadata like a regular Markdown based article (note the empty line at the end, you need it):Title:
Slug:
Date:
Category:
Tags:
Author:
Summary:You can specify to only include a subset of notebook cells with theSubcellsmetadata item.
It should contain the index (starting at 0) of first and last cell to include
(useNonefor open range).
For example, to skip the first two cells:Subcells: [2, None]Option 2: Metadata cell in notebookWith this option, the metadata is extracted from the first cell of
the notebook (which should be a Markdown cell), this cell is then ignored when the notebook is rendered.On yourpelicanconf.py:MARKUP=("md","ipynb")frompelican_jupyterimportmarkupasnb_markupPLUGINS=[nb_markup]IPYNB_MARKUP_USE_FIRST_CELL=TrueIGNORE_FILES=[".ipynb_checkpoints"]Now, 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: pipMode B: Liquid tagsOn yourpelicanconf.py:MARKUP=('md',)frompelican_jupyterimportliquidasnb_liquidPLUGINS=[nb_liquid]IGNORE_FILES=[".ipynb_checkpoints"]After this you can use a liquid tag to include a notebook in any regular markdown article,
for examplemypost.md:Title:
Slug:
Date:
Category:
Tags:
Author:
Summary:

{% notebook path/from/content/dir/to/notebook.ipynb %}Recommend mode?Personally I like Method A - Option 1 since I write the Notebooks first and then I just add
the metadata file and keeps the notebook clean.The Liquid tag mode provide more flexibility to combine an existing notebook code or output with extra text on a Markdown.
You can also combine 2 or more notebooks in this mode.
The only problem with the liquid tag mode is that it doesn't generate a summary for the article
automatically from the notebook so you have to write it in the source.mdfile that includes the notebook.sYou can use both modes at the same time but you are probably going to see a exception that
prevents conflicts, ignore it.Note on CSSIf the notebooks look bad on your pelican theme this can help.There is some issues/conflicts regarding the CSS that the Jupyter Notebook requires and the pelican themes.I do my best to make the plugin work with every theme but for obvious reasons I cannot guarantee that it will look good in any pelican theme.Jupyter Notebook is based on bootstrap so you probably will need your theme to be based on that it if you want the html and css to render nicely.I try to inject only the necessary CSS by removing Jupyter's bootstrap code and only injecting the extra CSS code.
In some cases but fixes are needed, I recommend looking at howmy themefixes them.You can suppress the inclusion of any Notebook CSS entirely by settingIPYNB_SKIP_CSS=True, this allows more flexibility on the pelican theme.TheIPYNB_EXPORT_TEMPLATEoption is another great way of extending the output natively using Jupyter nbconvert.SettingsNote:If you are using the Liquid mode you need to set the variables like this inside thepelicanconf.py.LIQUID_CONFIGS = (("IPYNB_EXPORT_TEMPLATE", "notebook.tpl", ""), )If you are using the Markup mode then just add this variables to yourpelicanconf.py.SettingDescriptionIPYNB_FIX_CSS = True[markup and liquid] Do not apply any of the plugins "fixes" to the Jupyter CSS use all the default Jupyter CSS.IPYNB_SKIP_CSS = False[markup and liquid] Do not include (at all) the notebook CSS in the generated output. This is usefull if you want to include it yourself in the theme.IPYNB_PREPROCESSORS[markup and liquid] A list of nbconvert preprocessors to be used when generating the HTML output.IPYNB_EXPORT_TEMPLATE[markup and liquid] Path to nbconvert export template (relative to project root). For example: Create a custom template that extends from thebasictemplate and adds some custom CSS and JavaScript, more info heredocsandexample here.IPYNB_STOP_SUMMARY_TAGS = [('div', ('class', 'input')), ('div', ('class', 'output')), ('h2', ('id', 'Header-2'))][markup only] List of tuples with the html tag and attribute (python HTMLParser format) that are used to stop the summary creation, this is useful to generate valid/shorter summaries.IPYNB_GENERATE_SUMMARY = True[markup only] Create a summary based on the notebook content. Every notebook can still use the sSummaryfrom the metadata to overwrite this.IPYNB_EXTEND_STOP_SUMMARY_TAGS[markup only] List of tuples to extend the defaultIPYNB_STOP_SUMMARY_TAGS.IPYNB_NB_SAVE_AS[markup only] If you want to make the original notebook available set this variable in a  is similar way to the default pelicanARTICLE_SAVE_ASsetting. This will also add a metadata fieldnb_pathwhich can be used in the theme. e.g.blog/{date:%Y}/{date:%m}/{date:%d}/{slug}/notebook.ipynbIPYNB_COLORSCHEME[markup only] Change the pygments colorscheme used for syntax highlightingIGNORE_FILES = ['.ipynb_checkpoints'][Pelican setting useful for markup] Prevents pelican from trying to parse notebook checkpoint files.Example template forIPYNB_EXPORT_TEMPLATE:{%- extends 'basic.tpl' -%}

{% block header %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

<style type="text/css">
div.code_cell {
    border: 2px solid red;
}
</style>
{%- endblock header %}