Skip to content

Replace instances of `absURL` method

We've used the absURL function in a few places (well, 41 places) on the site. This works fine for a local build, or if we only ran the site in one place, but this will not work for:

  • self-hosted docs sites, especially if they run offline
  • archives.docs.gitlab.com

This is because absURL evaluates to the baseURL from Hugo config, and that's https://new.docs.gitlab.com (or, eventually, https://docs.gitlab.com).

So, we end up with asset references with full absolute URLs like this:

<link rel="prefetch" href="https://new.docs.gitlab.com/gitlab_ui/fonts/GitLabMono.woff2" as="font" crossorigin="">

The site has to be able to run on other domains, and not be referencing assets over the internet. All paths have to be relative so that they're contained, and accessible from within, the current instance.

For example, an archive path reference should look like this:

<link rel="prefetch" href="/15.2/gitlab_ui/fonts/GitLabMono.woff2" as="font" crossorigin="">

I think we can just update everything to use relURL instead. 🤞

Edited by Sarah German