Introduction
The point of this tutorial is to show you how to add a compiled jupyter notebook to your website in a way that it can be viewed. There are two possible ways
- Save the compiled notebook (.ipynb) directly to your website and use a third party site to view content
- Export the compiled notebook to html or markdown and post to your website
Both methods are relatively easy to do and neither is more preferable than the other.
Option 1: Save the complied notebook directly
Start Jupyter notebook by opening up a command terminal and typing
jupyter notebook
In Jupyter notebook, load the notebook and select the “kernel” –> “restart and run all” menu item.
Save the notebook, then select “file” –> “close and halt”
Navigate to your github repository and select the “files” –> “upload files” menu item.
Select the .ipynb file, upload, and commit.
Create a special link to your file
Open up index.md or whatever file you would like to point to the new notebook from. Select edit
Add a new link. Remember, that links look like
[link text](http://www.mycustomurl.com/path/to/file)
. In our case, the link will start withhttps://nbviewer.jupyter.org/url/
and end with the path to your file,danaukestest01.github.io/vectors.ipynb
. The link text can be whatever you want it to be. So, for a full example, the whole link to an example file would look like this[link to vectors notebook](https://nbviewer.jupyter.org/url/danaukestest01.github.io/vectors.ipynb)
Save and commit your changes to index.md
Navigate to your website (myusername.github.io)
Try out the new link.
Option 2:
Start Jupyter notebook by opening up a command terminal and typing
jupyter notebook
Make sure your notebook starts with a markdown header that looks like the following:
--- title: this is a simple juptyer notebook ---
In Jupyter notebook, load the notebook and select the “kernel” –> “restart and run all” menu item.
Select “file” –> “download as” –> “markdown”. Save the file to disk when the option pops up.
Save the notebook, then select “file” –> “close and halt”
Unzip the file that was downloaded (if necessary).
Navigate to your github repository and select the “files” –> “upload files” menu item.
Select the .md file as well as any other unzipped files (if applicable), upload, and commit.
Create a link to your file
Open up index.md or whatever file you would like to point to the new notebook from. Select edit
Add a new link. Remember, that markdown files get compiled for you to html files. Thus, if you name it “simple.md”, github will convert that to a folder titled “/simple”. The link text can be whatever you want it to be. So, for a full example, the whole link to an example file would look like this
[link to simple markdown](/simple)
Save and commit your changes to index.md
Navigate to your website (myusername.github.io)
Try out the new link.