Fix language selector to preserve anchor links

What does this MR do and why?

The language selector now retains anchor links when switching between languages, ensuring users stay at the same section of the page after language changes.

Changes:

  1. Modified onLanguageSelect method to append current page hash to target URL
  2. Maintains existing behavior when no anchor links are present

Before: Switching languages would navigate to the top of the page

After: Users remain at the same section (e.g., #installation → /ja-jp/docs/page#installation)

Works with pages fully translated with english anchor links, such as /ja-jp/ci/yaml/#global-keywords For pages that don't have the english anchor link, that page just loads at the top.

Closes gitlab-com/localization/docs-site-localization#295 (closed)

Screenshots, screen recordings, or links to review app

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Enable Japanese in config/_default/hugo.yml
  2. Run site locally with make view
  3. Navigate to sub page and use the sidenav to append an anchor link to the URL, for example /ci/yaml/#artifactspaths
  4. Switch language, see the anchor link preserved

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.

Edited by Lauren Barker

Merge request reports

Loading
Loading