Skip to content

Linking to html files

Rini Banerjee edited this page Jul 29, 2020 · 2 revisions

Some notebooks will contain links to html files defined within the repository. They might look something like this:

If the link is not correctly formatted, clicking on it should take us to an error page:

What to do

Double clicking the cell will allow us to view the markdown. As an example, if we are in fdm-devito-notebooks/02_wave/wave1D_fd2.ipynb, we might see the following:

[web page](${doc_notes}/book/html/mov-wave/demo_BC_gaussian/index.html)

The problem here is the link to the the web page. Every section containing notebooks which reference web pages within the repository has a subdirectory called mov-<section>. Therefore, if we navigate to fdm-devito-notebooks/02_wave/mov-wave/demo_BC_gaussian, we see that there is indeed an index.html file. This is the file we want to link to, so all we do is replace the markdown with the following:

[web page](mov-wave/demo_BC_gaussian/index.html)

Now, when we run the cell, clicking on this link should take us to a screen that looks like this:

There should be an animation here, but because web pages are not allowed to access file:/// URLs for security reasons, we cannot see it on our local machine. To ensure that this works, check the notebook is still compiling, push your work to your branch and check NBViewer by navigating to the following link:

https://nbviewer.jupyter.org/github/devitocodes/devito_book/tree/<branch-name>/

where <branch-name> is the name of the branch you are working on.

In this example, if we navigate to this link and we click on the "web page" link in the first paragraph, we get taken to a page like this:

Clicking on the buttons allows us to control the animation, so our work here is done.