How to Share a Jupyter Notebook as a Link
nbviewer needs your notebook public on GitHub first. Here is how to share a Jupyter notebook as a link anyone can open, while keeping it private.
When people want to share a Jupyter notebook as a link, the usual answers are nbviewer or an exported HTML file, and both have a catch. nbviewer renders a notebook well, but only once it's public on GitHub or a Gist. nbconvert gives you a self-contained HTML file, which is still a file, so you're back to sending an attachment.
I built ShareMyPage, which is the third option I recommend below, so weigh that. Here is when each one fits.
nbviewer is right when the notebook is already public
If the notebook already sits in a public GitHub repo or Gist, nbviewer is the simplest answer and you don't need anything else.
It rules itself out for anything with customer numbers, salaries or unpublished results in it, because it only renders notebooks that are already public.
Export to one HTML file with embedded images
From the command line:
jupyter nbconvert --to html --embed-images analysis.ipynbIn JupyterLab, the same thing lives under File, Save and Export Notebook As, HTML.
--embed-images matters. Without it your plots can end up as references to files that never travel with the document, and the reader gets a page full of broken images. With it you get one analysis.html that carries its own charts, styling and output.
A private link is the better way to send it
This is for you if:
- the reader doesn't use Jupyter
- the notebook shouldn't be public
- you re-run the analysis and want the same link to show the new run
- Export the notebook to a single HTML file.
- Open ShareMyPage and drop that file in.
- Choose who can see it, then send the link.
The page renders at a clean URL, runs in a sandboxed frame, and keeps working when you re-run the analysis and replace it. The link doesn't change, so nobody has to be sent a second one.
You choose who gets in:
- anyone with the link, for a write-up you want indexed and quoted
- anyone with the link plus a password, when it goes to a client or a committee
- your workspace only, which suits most internal analysis
Interactive output keeps working too. A Plotly or Altair chart embeds its own JavaScript in the exported file, and the page runs that in a sandbox, so hover and zoom behave the way they did in your notebook.
Two downsides. It's a snapshot: readers see the output, but they can't run a cell or change a parameter. And embedded images make the file bigger, while the free plan caps a page at 2 MB (10 MB on paid plans), so a notebook full of plots can hit that.
A link beats the notebook file
A .ipynb asks the reader to have Jupyter. An .html attachment asks them to download something before they can look at it, and it opens badly on a phone. A link opens anywhere, previews properly in Slack, and always shows the current run rather than whichever copy somebody saved in March.
The short version
- Use nbviewer if the notebook is already public on GitHub.
- Send the
.ipynbif the reader needs to run it. - Use a ShareMyPage link if they only need to read it, and above all if it has to stay private.
One tip: always export with --embed-images. It's the difference between a report and a page of broken images.
If you publish analysis regularly, see how to share a Markdown file as a web page for notes and docs, and password-protecting a shared page for anything client facing.
Ready to send your next analysis as a link? Create a page on ShareMyPage and upload the exported HTML.