Add hreflang attribute to metaLinks.alternates for multilingual SEO #1202
Nicogugu
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context
We run a GitBook help center with two variants (FR + EN) under the same site. Each article exists in both languages with native slugs (
/fr/mon-article↔/en/my-article).Current behavior
Setting a per-page Alternate via Page options → Metadata (or git frontmatter
metaLinks.alternates) renders this in the HTML head:The
type=""attribute is empty. Nohreflang.Problem
Google's multilingual SEO guidelines require:
Without
hreflang, crawlers can't identify these pages as language variants of the same content. Each variant competes in isolation in its respective language market, duplicate-content penalties are possible, and users landing in the wrong-language variant aren't routed back by search engines.This is critical for any multilingual knowledge base targeting SEO — which is most customer-facing help centers.
Desired behavior
hreflangfield onmetaLinks.alternates[]entries — accepting standard values likeen,fr,de,x-default.hreflang="..."in the rendered<link rel="alternate">tag when set.hreflangfrom the target page's variant language when the alternate is set through the UI picker (since variants already have alanguagefield).Workaround attempted
Tried the object form in frontmatter:
Result: GitBook couldn't parse it and rendered
<link rel="alternate" type="" href=".../[object Object]/README.md" />— three broken links on the page.Impact
Critical for multilingual help centers that depend on SEO for discovery. Without this, every multilingual GitBook customer needs to either:
advancedCustomizationJS (works for rendering but Googlebot coverage is less reliable than HTML-static tags)Thanks!
Beta Was this translation helpful? Give feedback.
All reactions