Update help link redirect handling for Docs site Hugo launch
What does this MR do and why?
When the GitLab Docs website relaunches on Hugo, webpage URLs will change:
- Pages from
gitlabare no longer prefixed withee - The Hugo website uses "pretty URLs" (no
.htmlextensions)
Hugo also requires index.md pages to be named _index.md.
So, in this MR, we need to update logic in gitlab that translates a markdown file path to its website path.
This logic is used to redirect help links in the UI to the Docs website, if the GitLab instance is configured to use an external URL for help pages (like how gitlab.com is configured to use docs.gitlab.com).
References
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
Verify the docs redirect works for the pre-release version
- In GDK, update the "Documentation pages URL" setting to point to
https://docs.gitlab.com(this is the default, so it might already be there) - Click any help link in the UI. The link should resolve to the expected page on the new website. You can find several help links on this page: http://127.0.0.1:3000/help
Verify the docs redirect works for a released version:
- Modify the
version_segmentmethod inapp/controllers/help_controller.rb(line 121) to use a released version:
def version_segment
# Hardcode version for testing
"17.8"
# return if Gitlab.pre_release?
# version = Gitlab.version_info
# [version.major, version.minor].join('.')
end
- Visit a page with help links, like http://127.0.0.1:3000/help.
- Click a link, and you should be redirected to the appropriate page on
docs.gitlab.com/17.8(e.g, https://new.docs.gitlab.com/17.8/user/).
Edited by Sarah German