fix: canonicalize versioned doc pages to the version-less latest URL - #2070
Merged
Conversation
Versioned doc pages (/docs/<project>/<version>/...) self-canonicalize by default, so Google indexes each version as an independent page competing with the version-less latest URL. GSC shows the resulting traffic migration: e.g. /docs/apisix/plugins/cors/ clicks fell 69 -> 14 while /docs/apisix/3.10/plugins/cors/ rose 0 -> 38 in the last 28 days. Wrap theme LayoutHead to re-point canonical (and og:url) of versioned and /next/ doc pages at the version-less URL. Precedence is preserved by react-helmet's last-wins rule: a canonical embedded in the doc markdown itself (e.g. the docs.api7.ai links on latest pages) still overrides this wrapper, and version-less pages are untouched. Verified on a production build: - /docs/apisix/3.16/plugins/cors/ -> canonical https://apisix.apache.org/docs/apisix/plugins/cors/ - /zh/docs/apisix/3.16/plugins/cors/ -> canonical https://apisix.apache.org/zh/docs/apisix/plugins/cors/ - /docs/apisix/plugins/cors/ (latest) -> canonical https://docs.api7.ai/hub/cors (unchanged) - exactly one canonical link per page; og:url matches
Fails the deploy (before publishing) if a future Docusaurus or theme change silently breaks the one-canonical rule, the versioned->latest re-pointing, or the markdown-embedded canonical override.
Yilialinn
approved these changes
Jul 13, 2026
LiteSun
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.