Skip to content

fix: canonicalize versioned doc pages to the version-less latest URL - #2070

Merged
LiteSun merged 2 commits into
masterfrom
fix/versioned-docs-canonical
Jul 13, 2026
Merged

fix: canonicalize versioned doc pages to the version-less latest URL#2070
LiteSun merged 2 commits into
masterfrom
fix/versioned-docs-canonical

Conversation

@moonming

@moonming moonming commented Jul 13, 2026

Copy link
Copy Markdown
Member

No description provided.

moonming added 2 commits July 13, 2026 09:54
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.
@LiteSun
LiteSun merged commit 87991d1 into master Jul 13, 2026
4 checks passed
@Yilialinn
Yilialinn deleted the fix/versioned-docs-canonical branch July 13, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants