Use absolute URLs for images
What does this MR do and why?
Adds a render hook to rewrite image URLs so that they're always absolute.
We want to use an absolute path for images in order to avoid different behavior on pages that end with an extensionless URL and a trailing slash (see gitlab-org/gitlab-pages#354 (closed)).
This should also clear up a problem on the Hugo site where the prettyURLs
setting causes images on non-index.md pages to be broken, like this one: https://gitlab-org.gitlab.io/technical-writing-group/gitlab-docs-hugo/operations/metrics/#metric-details
Closes #69 (closed)
Screenshots, screen recordings, or links to review app
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
-
Configure a local GitLab Docs environment: https://gitlab.com/gitlab-org/technical-writing-group/gitlab-docs-hugo/-/blob/main/doc/setup.md. -
Browse the site and look for broken images. Here are some example pages that include images:
The local Hugo site should have working images for all of these, and if you inspect the HTML source, image paths are absolute, so they shouldn't vary by URL format like the current production site.
Merge request acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this merge request.
Closes #69 (closed)