Skip to content

canonical URL

canonical URL(规范链接)用于告诉搜索引擎页面的首选版本,避免重复内容对 SEO 排名的负面影响。当同一内容可以通过多个 URL 访问时,使用 canonical 标签指定规范的 URL。本节将介绍 canonical 的使用场景、配置方法、分页 canonical 策略,以及跨域名 canonical 的应用。

前置知识

阅读本节前,建议先了解:sitemap 与 robots

什么是 canonical

canonical 是一个 HTML 标签,用于指定当前页面的"规范"或"首选" URL。当搜索引擎发现多个 URL 指向相同或高度相似的内容时,它会合并这些 URL 的指标(如权重、外链),统一指向 canonical URL。

重复内容问题

常见重复内容场景

场景示例 URL问题
带有追踪参数/product?id=123&utm_source=google内容相同,URL 不同
大小写差异/Product vs /product同一内容
带有/不带尾部斜杠/blog/ vs /blog内容相同
HTTPS vs HTTPhttps:// vs http://应统一到 HTTPS
排序参数/products?sort=price vs /products?sort=date可能相同
分页/articles vs /articles?page=2部分相同
移动端适配m.example.com vs example.com同一内容
打印版本/article/print vs /article内容相同

canonical 用法

基本用法

html
<head>
  <!-- 指定规范 URL -->
  <link rel="canonical" href="https://example.com/product/wireless-headphones" />
</head>

自引用 canonical

html
<!-- 每个页面都应该指向自己的 canonical URL -->
<head>
  <link rel="canonical" href="https://example.com/about" />
</head>

自引用 canonical 的重要性

即使页面没有重复内容,也建议添加自引用 canonical。这能防止其他 URL 意外地"劫持"你的页面排名。

处理参数变体

html
<!-- 当前 URL: https://example.com/product?id=123&utm_source=google&campaign=spring -->
<!-- canonical 指向不带追踪参数的 URL -->
<head>
  <link rel="canonical" href="https://example.com/product?id=123" />
</head>

HTTPS 统一

html
<!-- 统一到 HTTPS 版本 -->
<head>
  <link rel="canonical" href="https://example.com/page" />
</head>

带或不带 www

html
<!-- 统一到带 www 的版本 -->
<link rel="canonical" href="https://www.example.com/page" />

<!-- 或统一到不带 www 的版本 -->
<link rel="canonical" href="https://example.com/page" />

分页 canonical

分页系列

分页页面应该自引用,而非都指向第一页:

html
<!-- 第 1 页 -->
<head>
  <link rel="canonical" href="https://example.com/articles?page=1" />
</head>

<!-- 第 2 页 -->
<head>
  <link rel="canonical" href="https://example.com/articles?page=2" />
</head>

<!-- 第 3 页 -->
<head>
  <link rel="canonical" href="https://example.com/articles?page=3" />
</head>

hreflang + canonical

多语言分页需要结合使用:

html
<!-- 中文版第 1 页 -->
<head>
  <link rel="canonical" href="https://example.com/zh-CN/articles?page=1" />
  <link rel="alternate" hreflang="zh-CN" href="https://example.com/zh-CN/articles?page=1" />
  <link rel="alternate" hreflang="en" href="https://example.com/en/articles?page=1" />
</head>

跨域名 canonical

当内容跨域名发布时,可以使用跨域名 canonical:

html
<!-- 原文发布在 example.com -->
<!-- 转载在 partner.com -->

<!-- partner.com 上的页面 -->
<head>
  <!-- canonical 指向原始来源 -->
  <link rel="canonical" href="https://example.com/original-article" />
</head>

跨域名 canonical 注意事项

  • 确保两个域名都经过验证
  • canonical 指向的页面应包含完整内容
  • 搜索引擎可能需要更长时间处理跨域名 canonical
  • 不要将 canonical 用于不相关的页面

HTTP 头中的 canonical

非 HTML 内容可以使用 HTTP 响应头指定 canonical:

Link: <https://example.com/product/123>; rel="canonical"

与其他 SEO 标签的关系

canonical vs noindex

场景使用
内容相同,需要合并权重canonical
不希望页面被索引noindex
同一内容不同语言版本hreflang

canonical vs 301 重定向

方式说明适用场景
canonical告诉搜索引擎合并权重内容相同但需要保留不同 URL
301 重定向直接跳转到目标 URL旧 URL 迁移到新 URL

注意事项

  1. canonical 必须是完整 URL:包含协议(https://)和域名
  2. canonical 应自引用:每个页面都应指向自己的 canonical
  3. 避免 canonical 链:A → B → C 的 canonical 链会被搜索引擎忽略
  4. canonical 指向的页面必须存在:不要指向 404 页面
  5. 确保一致性:URL 的大小写、协议、www 都要统一

最佳实践

  • 每个页面添加自引用 canonical
  • 统一协议到 HTTPS
  • 统一 www 或非 www
  • 处理追踪参数的 canonical
  • 分页使用自引用 canonical
  • 跨域名转载使用跨域名 canonical
  • 使用 Google Search Console 监控 canonical 错误

下一节

继续学习:关键渲染路径

参考链接