跳至正文
技术 SEO 与抓取索引 · Google SEO

Canonical Tags in SEO: Meaning, Examples and Verification

// / / 光算科技

A canonical URL is the preferred representative of a group of duplicate or very similar pages. A rel=canonical element tells Google which URL you prefer; it does not redirect the browser or force Google's selection. You do not need it to make every URL on a website point to one “main page.”

What the tag does—and what it does not

Google's canonicalization documentation lists rel=canonical and redirects as strong signals, and sitemap inclusion as a weaker one. Consistent signals help identify the preferred version. Google can still choose differently, and can recognize duplicates even when no preference is supplied.

A useful example is an article available at both /guide/ and /guide/?source=email with the same main content. A language translation, a second results page or a separate branch page needs its own assessment. Do not apply a site-wide rule based only on matching templates or a similarity percentage.

HTML example: put the declaration in a valid head

For this teaching example, replace the illustrative domain and path with the actual preferred URL. Output the declaration on the duplicate and on the preferred page itself:

<head>
  <title>Guide title</title>
  <link rel="canonical" href="https://example.com/guide/">
</head>

The example shows the relevant head fragment, not a complete page template. Google's documentation accepts the HTML canonical element only in the head. It does not specify a maximum line number or require it to sit immediately below the title. Invalid head markup can cause parsing problems, so inspect the response and the rendered DOM.

Use a fully qualified URL to avoid ambiguity across staging, protocol and host changes. Relative references are supported but not recommended by Google. A trailing slash should match the real route and chosen URL; neither always adding nor always removing one is a universal SEO rule. Do not select a fragment such as #comments as the canonical target.

HTTP-header example for non-HTML content

For a Word document whose preferred equivalent is a PDF, the response for the Word file could include:

Link: <https://example.com/downloads/manual.pdf>; rel="canonical"

This is a response header, not text to paste into the document or robots.txt. The documents must represent corresponding content. Google supports this canonical method for web search results; it is not a blanket rule to consolidate any downloadable file into a marketing page. Configure it through the actual server or application, then inspect a real GET response.

Google recommends choosing the HTML element or the HTTP header where appropriate. Both are supported, but using both increases the chance of conflicting destinations. A CMS field, plugin, theme and CDN rule can all affect the final output, so check the delivered result.

Common cases need different decisions

CaseInspect firstLikely direction
Tracking alias of the same articleWhether the main content really stays the samePoint duplicate versions to the stable representative
Permanently retired duplicateWhether a corresponding replacement existsUse a permanent redirect rather than retaining an unnecessary view
Page two of a listingWhether it contains later itemsKeep its own URL and canonical; do not point the whole sequence to page one
Complete language versionLanguage, content and localization relationshipsUse an appropriate same-language canonical and separate language annotations
Color or size variationSingle-page versus multi-page product modelFollow the actual model rather than merging every SKU
Page meant to leave searchWhether Google can fetch the exclusion ruleUse noindex for exclusion, not to select a canonical

The pagination rule comes from Google's pagination guide; variant implementation has its own single-page and multi-page requirements. For broader choices, see handling duplicate pages without deleting them and parameter URLs by purpose.

Check for conflicting signals

  • One plugin declares URL A while a response header declares URL B.
  • The preferred page redirects elsewhere, returns an error or is unavailable to the crawler.
  • Internal links and the sitemap promote an unintended duplicate.
  • JavaScript replaces a correct source declaration with another URL.
  • The claimed duplicate actually answers a different question or serves another language.

For JavaScript sites, Google recommends making the canonical clear in source HTML and avoiding changes to it during rendering. If it cannot be set in source, the documentation permits setting it with JavaScript instead; do not manufacture conflicting versions.

Robots.txt is not a canonicalization tool. Noindex requires crawl access and excludes a page from search; it is not Google's recommended way to decide which duplicate should be canonical. Do not block a page and then assume Google has read its canonical element.

Verify the declared URL and Google's chosen URL separately

Fetch a representative set of page types, record their HTTP headers and initial HTML, and inspect the rendered head. Then use URL Inspection to compare the user-declared and Google-selected canonicals in indexed data. Its live test does not predict the canonical Google will select.

If the selection is unexpected, follow Google's troubleshooting sequence: inspect technical conflicts, assess actual similarity and consider whether the selected page better serves the user. Reprocessing takes time; a successful test is not proof of ranking improvement. 中文设置说明:canonical、常见误配与核验。