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 gitlab are no longer prefixed with ee
  • The Hugo website uses "pretty URLs" (no .html extensions)

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

  1. 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)
  2. 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:

  1. Modify the version_segment method in app/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
  1. Visit a page with help links, like http://127.0.0.1:3000/help.
  2. 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

Merge request reports

Loading