GEO
GEO Docs

多语言与 hreflang

四种 URL 策略、hreflang 与 x-default 的输出规则,以及语言识别。

URL 策略

在 站点管理 → 语言 选择:

策略形态hreflang href
path-prefix(默认)/en/post、/ja/posthttps://example.com/en/post
subdomainen.example.com/posthttps://en.example.com/post
domainexample.com / example.jp每种语言配置自己的域名
none单语言站点只输出 canonical

自动输出

对每个启用的语言,SDK 输出:

<link rel="alternate" hreflang="zh-Hans" href="https://example.com/zh-CN/post" />
<link rel="alternate" hreflang="en" href="https://example.com/en/post" />
<link rel="alternate" hreflang="x-default" href="https://example.com/zh-CN/post" />

zh-CN 映射为 zh-Hans,zh-TW 映射为 zh-Hant,其余按 BCP 47 原样输出;x-default 指向站点默认语言。

语言识别

data-locale="auto" 时按策略识别:路径前缀、子域名或域名。无法识别时使用站点默认语言。也可以在页面变量里显式传 locale。

翻译缺失

某语言没有对应页面时,建议在后台把该语言的 自动翻译 打开;在翻译完成前 SDK 不会为缺失语言输出 hreflang,避免指向 404。

与 Next.js 的配合

geoMetadata() 把 hreflang 写入 alternates.languages;next-intl 等库的路由前缀与站点策略保持一致即可。