Posting Jupyter Notebooks On Medium

Saad Elbeleidy
plata
Published in
2 min readJan 19, 2017

Medium allows you to easily embed GitHub gists into an article and GitHub renders Jupyter Notebooks from gists. So all you have to do is post your notebook’s contents into a gist and embed it. Here’s an example:

Jupyter Notebook In Medium!

Now, if you already have a git repo that you’re using for the notebook you can’t just embed it from there. The easiest way to do that is to add a gist as a remote. There’s one main catch though; your repo must not have any folders.

Here’s how to add a gist as a remote:

  1. Go to gist.github.com and create a new gist
  2. You can call it whatever you like, but make sure to add a file otherwise you won’t be able to create the gist
  3. On the gist’s page you should be able to find a url to clone the gist, copy that
  4. If you use GitKraken or some other tool, you can add the remote that way, otherwise, open terminal, go to your git repo and then type git remote add gist <url-you-copied> (You can replace “gist” with another name, but be sure to use that name in the next step)
  5. Then in terminal, type git push gist master --force
  6. Voila! You should have a gist that has all the code from your repo. Don’t forget to push to both origin and gist when you update your notebook!

Note: I’m still having an issue with embedding just one file on medium instead of all files of a gist. Will update once I figure out a way around that.

--

--

Saad Elbeleidy
plata
Editor for

Robot Teleoperation Interface Researcher interested in Machine Learning, Data Visualization, Algorithmic Bias, and Food