Hreflang 标签生成器
为多语言和多地区网站生成 hreflang 标签。支持 HTML 链接标签、HTTP 标头和 XML 站点地图格式,内置验证和智能 URL 自动填充功能。
<link rel="alternate" hreflang="en" href="https://example.com/product" /> <link rel="alternate" hreflang="ja" href="https://example.com/ja/product" /> <link rel="alternate" hreflang="ko" href="https://example.com/ko/product" /> <link rel="alternate" hreflang="zh-hans" href="https://example.com/zh/product" /> <link rel="alternate" hreflang="zh-hant" href="https://example.com/zh-tw/product" /> <link rel="alternate" hreflang="x-default" href="https://example.com/product" />
Link: <https://example.com/product>; rel="alternate"; hreflang="en",
<https://example.com/ja/product>; rel="alternate"; hreflang="ja",
<https://example.com/ko/product>; rel="alternate"; hreflang="ko",
<https://example.com/zh/product>; rel="alternate"; hreflang="zh-hans",
<https://example.com/zh-tw/product>; rel="alternate"; hreflang="zh-hant",
<https://example.com/product>; rel="alternate"; hreflang="x-default"
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/product</loc>
<xhtml:link rel="alternate" hreflang="en"
href="https://example.com/product" />
<xhtml:link rel="alternate" hreflang="ja"
href="https://example.com/ja/product" />
<xhtml:link rel="alternate" hreflang="ko"
href="https://example.com/ko/product" />
<xhtml:link rel="alternate" hreflang="zh-hans"
href="https://example.com/zh/product" />
<xhtml:link rel="alternate" hreflang="zh-hant"
href="https://example.com/zh-tw/product" />
<xhtml:link rel="alternate" hreflang="x-default"
href="https://example.com/product" />
</url>
<url>
<loc>https://example.com/ja/product</loc>
<xhtml:link rel="alternate" hreflang="en"
href="https://example.com/product" />
<xhtml:link rel="alternate" hreflang="ja"
href="https://example.com/ja/product" />
<xhtml:link rel="alternate" hreflang="ko"
href="https://example.com/ko/product" />
<xhtml:link rel="alternate" hreflang="zh-hans"
href="https://example.com/zh/product" />
<xhtml:link rel="alternate" hreflang="zh-hant"
href="https://example.com/zh-tw/product" />
<xhtml:link rel="alternate" hreflang="x-default"
href="https://example.com/product" />
</url>
<url>
<loc>https://example.com/ko/product</loc>
<xhtml:link rel="alternate" hreflang="en"
href="https://example.com/product" />
<xhtml:link rel="alternate" hreflang="ja"
href="https://example.com/ja/product" />
<xhtml:link rel="alternate" hreflang="ko"
href="https://example.com/ko/product" />
<xhtml:link rel="alternate" hreflang="zh-hans"
href="https://example.com/zh/product" />
<xhtml:link rel="alternate" hreflang="zh-hant"
href="https://example.com/zh-tw/product" />
<xhtml:link rel="alternate" hreflang="x-default"
href="https://example.com/product" />
</url>
<url>
<loc>https://example.com/zh/product</loc>
<xhtml:link rel="alternate" hreflang="en"
href="https://example.com/product" />
<xhtml:link rel="alternate" hreflang="ja"
href="https://example.com/ja/product" />
<xhtml:link rel="alternate" hreflang="ko"
href="https://example.com/ko/product" />
<xhtml:link rel="alternate" hreflang="zh-hans"
href="https://example.com/zh/product" />
<xhtml:link rel="alternate" hreflang="zh-hant"
href="https://example.com/zh-tw/product" />
<xhtml:link rel="alternate" hreflang="x-default"
href="https://example.com/product" />
</url>
<url>
<loc>https://example.com/zh-tw/product</loc>
<xhtml:link rel="alternate" hreflang="en"
href="https://example.com/product" />
<xhtml:link rel="alternate" hreflang="ja"
href="https://example.com/ja/product" />
<xhtml:link rel="alternate" hreflang="ko"
href="https://example.com/ko/product" />
<xhtml:link rel="alternate" hreflang="zh-hans"
href="https://example.com/zh/product" />
<xhtml:link rel="alternate" hreflang="zh-hant"
href="https://example.com/zh-tw/product" />
<xhtml:link rel="alternate" hreflang="x-default"
href="https://example.com/product" />
</url>
</urlset>
检测到广告拦截,导致我们无法展示广告
MiniWebtool 依靠广告收入免费提供服务。如果这个工具帮到了你,欢迎开通 Premium(无广告 + 更快),或将 MiniWebtool.com 加入白名单后刷新页面。
- 或升级 Premium(无广告)
- 允许 MiniWebtool.com 显示广告,然后刷新
Hreflang 标签生成器
hreflang标签生成器可以为多语言和多地区网站创建格式正确的 hreflang 注释。它支持三种实现方法——HTML 链接标签、HTTP 响应标头和 XML 站点地图——并包括智能 URL 自动填充、从现有标记导入、语言预设和内置验证功能,帮助您避免可能损害国际 SEO 的常见 hreflang 错误。
如何使用此工具
- 添加语言版本 — 为页面的每个语言版本输入 hreflang 语言-地区代码(例如
en,es,fr-ca)和完整 URL。使用自动完成建议或输入您自己的代码。 - 使用自动填充(可选) — 输入基础 URL 并选择“子目录”或“子域名”模式,为每个语言条目自动生成 URL。
- 添加 x-default — 包含一个指向回退页面(通常是您的主要语言版本或语言选择页面)的
x-default条目。 - 生成标签 — 点击“生成标签”以生成所有三种格式的输出。查看任何验证警告。
- 复制并实现 — 使用选项卡式输出复制您需要的格式。对于 HTML,将标签粘贴到每个语言版本的
<head>中。对于 XML 站点地图,下载文件并将其上传到您的服务器。
用户
hreflang
西班牙语页面
了解 Hreflang 属性
Hreflang 是谷歌在 2011 年引入的一种 HTML 属性,旨在帮助网站管理员指示网页的语言和地理定位。当一个网站拥有多种语言的内容或地区差异(例如,面向美国的英语与面向英国的英语)时,hreflang 标签会根据用户的语言和位置告诉搜索引擎在搜索结果中显示哪个版本。
hreflang 值遵循 language-region 格式,其中:
- 语言代码 (Language code) — ISO 639-1 两位字母代码(例如
en代表英语,es代表西班牙语,ja代表日语) - 地区代码 (Region code) (可选) — ISO 3166-1 Alpha 2 国家代码(例如
us代表美国,gb代表英国,mx代表墨西哥)
特殊代码如 zh-hans(简体中文)和 zh-hant(繁体中文)使用脚本子标签而非地区代码。
实现方法对比
HTML 链接标签 最常用
将 <link> 元素放置在每个页面的 <head> 部分。实现简单,适用于大多数网站。
hreflang="en"
href="https://example.com/" />
最适合: 拥有适量语言版本的标准 HTML 网站。
HTTP 标头 针对非 HTML
在 HTTP 响应标头中发送 hreflang 信息。对于没有 HTML <head> 的文件(如 PDF)非常有用。
rel="alternate";
hreflang="en"
最适合: PDF 文件、非 HTML 文档以及可以配置服务器标头的网站。
XML 站点地图 针对大型网站
使用 xhtml:link 元素将 hreflang 注释添加到 XML 站点地图中。是拥有大量页面和语言版本的网站的理想选择。
hreflang="en"
href="https://example.com/" />
最适合: 拥有数百或数千个多语言页面的大型网站。
应避免的常见 Hreflang 错误
- 缺少互惠标签: hreflang 标签中引用的每个页面都必须链接回所有其他语言版本。如果页面 A 引用了页面 B,则页面 B 也必须引用页面 A。非互惠标签会被搜索引擎忽略。
- 缺少自我引用标签: 每个页面都应包含一个指向自身的 hreflang 标签。这向搜索引擎确认该页面确实是该 hreflang 集合的一部分。
- 忘记 x-default: 务必包含
x-default标签,以处理语言/地区与任何指定 hreflang 标签都不匹配的用户。如果没有它,搜索引擎就没有回退指令。 - 使用错误的语言代码: 使用 ISO 639-1 语言代码和 ISO 3166-1 Alpha 2 地区代码。常见错误包括将英国英语使用
uk而非en-gb,或将日语使用jp而非ja。 - 混合协议或域名: 所有 hreflang URL 应使用相同的协议(首选 HTTPS)并与规范 (canonical) URL 完全匹配。hreflang URL 与规范标签之间的不匹配会导致搜索引擎困惑。
最佳实践
- 在 hreflang 标签中始终使用绝对 URL(包括
https://),切勿使用相对路径。 - 在每个页面上包含一个自我引用的 hreflang 标签。
- 添加指向主要版本或语言选择页面的
x-default标签。 - 确保 hreflang URL 与每个页面的规范 (canonical) URL 完全一致。
- 每个页面仅使用一种实现方法(不要为同一页面混合使用 HTML 标签和站点地图注释)。
- 定期使用此工具、Google Search Console 或其他 SEO 审核工具验证 hreflang 标签。
- 对于针对不同地区相同语言的页面(例如
en-us和en-gb),务必同时包含语言和地区代码。
常见问题解答
什么是 hreflang 标签?
Hreflang 标签是 HTML 属性,用于告诉搜索引擎应向用户显示页面的哪个语言和区域版本。它们使用 rel="alternate" hreflang="x" 属性来指示语言替代方案,帮助搜索引擎根据用户的语言和位置提供正确的版本。
我应该把 hreflang 标签放在哪里?
Hreflang 标签可以放置在三个位置:HTML <head> 部分作为 <link> 元素、HTTP 响应标头中或 XML 站点地图中。HTML head 方法最适用于标准网站,HTTP 标头适用于 PDF 等非 HTML 文档,而 XML 站点地图则是具有多个语言版本的大型网站的理想选择。
hreflang 中的 x-default 是什么?
x-default 值是一个特殊的 hreflang 属性,用于为语言或地区与任何指定 hreflang 标签都不匹配的用户指定默认或回退页面。谷歌建议始终包含一个指向主要语言版本或语言选择页面的 x-default 标签。
hreflang 标签需要是互惠的吗?
是的,hreflang 标签必须是互惠的(也称为双向)。如果页面 A 使用 hreflang 标签链接到页面 B,则页面 B 也必须使用相应的 hreflang 标签链接回页面 A。如果缺少互惠链接,搜索引擎可能会完全忽略 hreflang 注释。
hreflang 中的语言和地区有什么区别?
在 hreflang 标签中,语言代码(如 en, es, fr)使用 ISO 639-1 格式并指定内容语言。可选的地区代码(如 us, gb, mx)使用 ISO 3166-1 Alpha 2 格式并针对特定国家。例如,en-us 针对美国的英语用户,而 en-gb 针对英国的英语用户。
引用此内容、页面或工具为:
"Hreflang 标签生成器" 于 https://MiniWebtool.com/zh-cn//,来自 MiniWebtool,https://MiniWebtool.com/
由 miniwebtool 团队开发。更新日期:2026-03-10