How to replace a Jupyter notebook with a newer version, and get it visible with nbviewer?

Hello,

If I create a post in the ‘Share’ section and upload a Jupyter notebook file (.ipynb), then automatically the post will be enriched with a line:

“Click here to view the jupyter notebook file in a new tab”

Very nice!

Then, however, I just replaced the .ipynb file with a newer version. However, when clicking “Click here to view…” it still appears to show the old version.

What can I do about this?

Kind regards,
Jasper

1 Like

Hi Jasper,

You should do the following:

  1. Open your post to edit again.
  2. Remove the link on your old notebook.
  3. Instead, add the following link at the end:
[Click here to view the jupyter notebook file in a new tab](https://nbviewer.jupyter.org/urls/community.dataquest.io/uploads/short-url/aDh8fdMgLpn7EnTAkau0zXHRphe.ipynb)

(Side note: don’t worry that it looks strange above. I wrote it in a code mode, because if I write it in a markdown mode, it will be automatically rendered as a link, and you won’t see the actual text. You should write it in a normal markdown mode, of course).

  1. Substitute the last part of the link above (the one after the last slash, i.e. aDh8fdMgLpn7EnTAkau0zXHRphe.ipynb) with the name of your own notebook.

How to find the name of your notebook?
I’ll show you by the example of one of my posts:
nb

This long combination of characters after upload:// is the name of my file, i.e. 8ACJWKZWSigkzIYMtHfqAEJSPLw.ipynb In your case, the combination will be different, of course. Copy this combination and substitute the last part of the link above.

Important: when substituting the example name with your own notebook name, be careful not to add any extra white space between the slash and your notebook name.

  1. Now, save edit and publish your post.
3 Likes

Awesome, thank you! Will try it out!

1 Like