Skip to content

docs: send readers to their language and list translated sitemaps - #16314

Merged
devGregA merged 1 commit into
DefectDojo:devfrom
devGregA:devgrega/docs-lang-redirect
Oct 13, 2026
Merged

devGregA merged 1 commit into
DefectDojo:devfrom
devGregA:devgrega/docs-lang-redirect

Conversation

@devGregA

Copy link
Copy Markdown
Contributor

What

Language redirect. A reader who arrives on an English docs page from outside the site now lands on the same page in their language, if that page has a translation. The language comes from:

  1. The language they last picked in the header language menu (saved in localStorage).
  2. Otherwise, the first of their browser's preferred languages that we translate. If English comes first in that list, they stay on English.

It never redirects:

  • clicks within the docs, so a reader can pick English from a translated page and stay there, and the untranslated sections that translated pages link to (releases, supported_tools) don't bounce back
  • crawlers
  • pages without a translation

Traditional Chinese browsers stay on English rather than going to Simplified. All Portuguese variants go to pt-br. The redirect uses location.replace and keeps the query string and anchor, so the back button never loops.

Sitemaps. The root /sitemap.xml only lists English pages. Each language has its own /<lang>/sitemap.xml, but nothing pointed to them. robots.txt now lists all eight.

Why

Two weeks of site analytics show that few readers find the translations. For example, 93 docs visitors had German browsers but only 8 opened a German page. Each page already has correct hreflang tags. The gaps were search engines never being shown the translated sitemaps and readers never being sent to their language.

Testing

  • Production build (hugo --minify --config config/production/hugo.toml) is clean.
  • The script appears only on English pages that have translations (checked the home page and a guide page). It is absent from translated pages and from untranslated sections.
  • Ran the built, minified script against 18 cases using mocked browser objects. Results: de-DE, fr-CA, pt-PT, pt-BR, zh-CN and bare zh redirect to the right language. en-before-de, zh-TW, zh-Hant-TW and ko-only stay on English. A browser listing ru then de goes to de. A saved en beats a German browser, and a saved es beats a German browser. An internal referrer doesn't redirect, while an external referrer from Google does. Googlebot doesn't redirect, and query plus hash are kept.
  • Clicking a language in the header menu saves it, and clicking other links doesn't change it.

🤖 Generated with Claude Code

A reader arriving on an English docs page from outside the site now lands on
the same page in their language when a translation exists: the language they
last picked in the header menu, or else their browser's first translated
preference. Internal clicks, crawlers and readers whose browser prefers
English are never redirected.

robots.txt now lists every language's sitemap. The root sitemap only covers
English, so the translated pages were missing from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devGregA
devGregA enabled auto-merge October 13, 2026 00:43
@github-actions github-actions Bot added the docs label Oct 13, 2026
@devGregA
devGregA disabled auto-merge October 13, 2026 04:16
@devGregA
devGregA merged commit 07a072b into DefectDojo:dev Oct 13, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant