Convert a .ipnb
to .html
for Jekyll
.
You can find this package at here.
-
Add this repository into your main directory.
-
Exclude it in
_config.yml
like the following.exclude: - notebook-to-html-jekyll
-
Ignore it if you use git by running
echo "\nnotebook-to-html-jekyll\n" >> .gitignore
. -
Run from your main directory
python3 notebook-to-html-jekyll --prepare
.
Now, you are ready to convert a .ipynb
to a .html
file for Jekyll
.
Convert a .ipynb
file to .html
by
running
python3 notebook-to-html-jekyll --convert path/to/your/file.ipynb
Get the .html
file in the same path as your .ipynb
file.
Include your notebook in your jekyll site using the following
---
{% include_relative notebook-file-name.html %}
---
_includes
matjax-setup.html
notebook-css.html
prepare
convert
__init__.py
-
add includes to
_includes/
cp notebook-to-jekyll/_includes/* _includes/
-
add layout to
_layout/
- for
layout.html
in_layout/
directory- run
cp _layout/{{layout}}.html _layout/{{layout}}-notebook.html
- if
_layout/{{layout}}-notebook.html
containslayout: {layout-name}
- append
-notebook
tolayout: {layout-name}
(i.e.layout: {layout-name}-notebook
)
- append
- else
- edit
<head ... </head>
of_layout/{{layout}}-notebook.html
- add
{% include matjax-setup.html %}
- add
{% include noteboo-css.html %}
- add
- edit
- run
- for
- Make Jekyll's
.html
from.ipynb
- run
jupyter-nbconvert path/input/file.ipynb --to html
It will generatepath/input/file.html
. - Edit
path/input/file.html
- delete everything except
<body ... </body>
- replace
body
tag withdiv
tag. - put
{{
,}}
,{%
and%}
in{% raw %} ... {% endraw %}
block.
- delete everything except
- run