Sharing interactive plots on GitHub

Interactive plots are really nice but of course it would be nice to be able to show them to your friend also, wouldn’t it?

Luckily, there is a really easy way of doing this using GitHub and their specific feature called GitHub Pages which you can easily combine into your GitHub repositories.

Here is a short video demonstrating what all you can do with GitHub pages:

How the repository should be organized?

For the purpose of sharing our maps on GitHub, we will use the Exercise 5 repository where we will upload our maps. You can follow these instructions on GitHub after accepting the Github classroom invitation link for Exercise 5.

When you want to publish something on GitHub Pages, it is generally a good idea to store your html files (such as the ones we made earlier) under a single folder called docs which should be located on the root of your repository. The Exercise 5 repository already contains such a folder: the folder docs:


Thus, all your html maps and plots should be stored there! Why? Because we can set up GitHub to search our html files from there by default and storing those files under a separate folder keeps things nicely organized.

What is currently located there are following files:


Thus, there is already a single map that I have made called test_map.html, a html file called index.html and the most important file for us called

Let’s see how does the file look like (here is a link to the actual page on our public repository):


Okey, so we can see that this is a familiar looking page with some Markdown text and links. What is the purpose of this page is to serve as an entrance page for you interactive plots. Thus as the page say, you should add links to your maps that are published from your personal Exercise 5 located at (for example, the address for vuokko’s exercise 5 submission is

Okey but how does that work, how do I get a page with such an address?

The magic here is something where GitHub Pages comes into a picture. That address is going to be created when I activate the GitHub Pages for my Exercise 5 repository.

Let’s see how that can be done. Luckily it’s easy.

Activating GitHub Pages

First, you should navigate into the Settings of your Exercise 5 repository by clicking following tab on the right side of the upper panel:


In there you can adjust different Setting regarding your repository but what we are interested in is a section called GitHub Pages which can be found when you scroll down a little bit. It looks like following:


From there you should choose the source for your pages, i.e. the place where those html files are searched from. You should choose the master branch /docs folder which is the location that we just visited earlier and where we should store our html files:


Finally, you should press the Save button and after that GitHub Pages are activated for you!


Accessing GitHub Pages

Now if I press the link that is shown above I will arrive into a following page:


This page is showing the contents of the index.html file that was also located in our docs folder.

Note, that in this exercise we won’t be practicing how to write HTML code and therefore we will use the file under the docs-folder to maintain the links, as you already know how to write Markdown.

We can now navigate to whatever file that is located under that folder. Thus, we can for example access the test_map.html by typing:

Ahaa! So this means that if you upload e.g. an interactive map that you have prepared into that folder you are able to access it also from anywhere. And also share it with your friends! You just need to change the name of the html file according the filename that you have uploaded. So this is how we can easily share interactive maps on GitHub for anyone.


Notice that even though your personal Exercise 5 repository in GitHub is private and no-one else can access it, all the files that you store under the docs folder CAN BE ACCESSED by anyone. So keep this in mind when using GitHub Pages.


Notice that now you can also do your personal GitHub Pages where you can store and share all sorts of cool stuff that you have created yourself! You just need to create your own repository and follow exactly the same steps that were mentioned here.