# 为多语言页面设置 hreflang

> 在每个语言版本上添加 hreflang 标注，列出所有版本（包括它自己）。标注必须双向互指，使用有效的语言代码（地区代码可选），并指向规范的、可索引的 URL。

- URL: https://geo.casa/zh-cn/crawling-indexing/hreflang/
- 指南 · 官方文档已说明
- 审核于: 2026-10-24

## 什么时候需要

同一内容存在多个语言或地区版本时，例如 `/guide/`（英文）和 `/zh-cn/guide/`（简体中文）。它帮助 Google 向用户展示合适的版本。单一语言的网站不需要它来获得排名。

## 步骤

1. **选择一种方式**：HTML `<link>` 标签、HTTP 响应头或 Sitemap 条目。Google 将三者视为等效。
2. **在每个版本上列出所有版本，包括页面自身：**

   ```html
   <link rel="alternate" hreflang="en" href="https://example.com/guide/" />
   <link rel="alternate" hreflang="zh-CN" href="https://example.com/zh-cn/guide/" />
   <link rel="alternate" hreflang="x-default" href="https://example.com/guide/" />
   ```
3. **使用有效代码**：ISO 639-1 语言代码，可选地加上 ISO 3166-1 alpha-2 地区代码（写 `zh-CN`，不要写 `cn`）。
4. **添加 `x-default`**，作为没有匹配版本时展示的回退页面。

> **官方文档已说明:**
> 如果两个页面没有互相指向，这些标签会被忽略。每个语言版本都应列出自身以及所有其他版本。
>
> 参考来源: [Google Search Central: Tell Google about localized versions of your page](https://developers.google.com/search/docs/specialty/international/localized-versions)

## 验证

- 查看每个版本的源代码，确认 `hreflang` 链接集合完全一致。
- 每个 `href` 都应返回 `200`、使用自引用 canonical，并且不是 `noindex`。这是本站的建议，hreflang 指南本身没有把它列为规则。

## 常见错误

- 为并不存在的翻译输出 hreflang，例如某些 CMS 会在 `/zh-cn/` URL 下以英文内容作为回退。只应标注真实存在的翻译。（本站在构建时会删除这类标签。）
- 把各语言版本的 canonical 指向英文页面，这等于告诉 Google 它们是重复内容。见 [规范网址（canonical）信号](https://geo.casa/zh-cn/crawling-indexing/canonical-signals/)。

## 参考来源

- [Google Search Central: Tell Google about localized versions of your page](https://developers.google.com/search/docs/specialty/international/localized-versions)
