# canonical 参考

URL: https://caijiao.org/reference/html/canonical
Source: docs/reference/html/canonical.md
Description: canonical Reference，整理 rel=canonical 的写法、规范 URL、重复页面处理、SEO 注意事项和常见错误。

canonical 用于告诉搜索引擎当前页面的规范 URL。它常用于处理参数页、分页筛选、HTTP/HTTPS、www/非 www 和重复内容问题。

## 语法

```html
<link rel="canonical" href="https://caijiao.org/reference/html/canonical">
```

## 使用场景

- 同一内容有多个 URL 版本。
- 参数 URL 和无参数 URL 内容基本一致。
- HTTP / HTTPS 或 www / 非 www 需要统一。
- 内容迁移后仍保留旧页面一段时间。

## 使用要点

- canonical 的 `href` 应使用完整绝对 URL。
- 页面自己也可以指向自己，作为自引用 canonical。
- canonical 是搜索引擎信号，不是强制跳转；需要跳转时使用 301/308。
- sitemap、站内链接、canonical 应尽量指向同一规范 URL。

## 常见错误

- canonical 指向不存在、被 robots 屏蔽或 noindex 的页面。
- 分页、筛选页全部 canonical 到首页，导致有效页面难以被识别。
- canonical 与重定向目标、sitemap URL 不一致。
- 把 canonical 当成阻止索引工具；真正不希望索引应考虑 `noindex`。

## 相关内容

- [HTML Reference](/reference/html/)
- [HTTP Redirect 参考](/reference/http/redirect)
- [canonical 标签应该怎么写](/how-to/seo-website/canonical-setup)
- [URL 末尾斜杠要统一吗](/how-to/seo-website/trailing-slash)
- [Google Search Central](/google-search-central/)
- [Google canonical 文档](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls)
