How do I create a relative link in Jupyterlab?

I’m launching jupyter lab locally and have it listen to https://127.0.0.1:8888.

The output of the following cell

%%html
<a href="relative/link.html">relative link</a>

will link to http://127.0.0.1:8888/files/relative/link.html.

There’s been a lot going on in this respect in the jupyterlab github repo (@consideRatio led some of the discussions), but I could not really figure out if the related PRs were providing the desired solution and if / when these will make it to a Jupyterlab release.

Im still a bit confused but I think we need to get even more explicit what we look to accomplish.

You can do notebook file location relative links, and domain name relative links, i think, and absolute links… I wonder if you could not get notebook server relative links and that was one of my issues, because the notebook server is sometimes available on https://hub.example.com/hub/erik/ rather than the root of a domain. If you are on a jupyterhub and can use a domain relative link then you can prepend /hub/user-redirect though…

Hmmm…
notebook file location relative: wonderland/kitten.ipynb
domain relative: /lab/tree/cat.ipynb
absolute: https://cat.meow/purr

Yeah im still very uncertain about things

1 Like