SEO100
SEO method 22 of 100

Canonical Tags: How to Tell Google Which URL to Index

Intermediate Medium impact A few hours Technical SEO

Updated · First published

Short answerA canonical tag names the preferred URL when several URLs show the same content. Google treats it as a signal, not a command: use absolute URLs, put it in the head, point every page at itself, and check the Google-selected canonical in URL Inspection.

A canonical tag (rel="canonical") is a line of HTML that tells search engines which URL is the preferred version of a page when the same or very similar content lives on more than one address. Google groups the duplicates, picks one URL to show in results, and treats your canonical tag as one signal in that choice.

What is a canonical tag?

The tag sits in the <head> of a page and points to the preferred URL:

<link rel="canonical" href="https://example.com/shoes/red-trainers/" />

Duplicate URLs appear on almost every site. Think of http:// and https://, www and non-www, a trailing slash or none, tracking parameters like ?utm_source=news, filter and sort parameters on category pages, and print or mobile versions. Each variant is a separate address to Google, even if the content is identical.

For non-HTML files such as PDFs you cannot add a tag, so you send the same information in an HTTP header: Link: <https://example.com/guide.pdf>; rel="canonical". Google supports this header for web search.

Why do canonical tags matter for SEO?

When Google finds duplicates it has to pick one. Without your guidance it picks whichever version it judges best, which may be the parameter URL with tracking junk, not your clean one. Clear canonical signals do three things:

  • Combine ranking signals such as links onto one URL instead of splitting them across variants.
  • Save crawl effort on large sites, because Google spends less time on duplicates.
  • Control what searchers see: the address shown in results and reported in Search Console.

A canonical is a hint, not a directive. Google’s documentation describes redirects, rel="canonical" and sitemap inclusion as signals of your preference, and says Google still decides which pages are duplicates. A redirect is the strongest signal, rel="canonical" is strong, and a sitemap entry is weak.

Which canonical rules does Google follow?

Rule What Google says
Location The link element is accepted only in the <head>, so the head must be valid HTML.
URL format Use absolute URLs. Relative paths work but cause trouble when a test site gets crawled.
Self-reference Add a canonical to the canonical page itself, pointing to its own URL.
One method Choose the HTML element or the HTTP header. Using both is supported but easy to get wrong.
Fragments Do not use a URL fragment (#section) as the canonical.
noindex Do not use noindex to steer canonical choice within a site. It removes the page from search entirely.
robots.txt Do not use it for canonicalization. Google can still index disallowed URLs without their content.
Language versions A canonical with hreflang, lang, media or type attributes is ignored. Use rel="alternate" (see hreflang).
JavaScript Put the canonical in the HTML source. If you cannot, set it only with JavaScript and do not let scripts change a tag that exists already.

How do you set up canonical tags, step by step?

  1. Decide the one preferred URL for each page. Pick HTTPS, one hostname (www or non-www) and one trailing-slash style, and keep it site wide. This ties into your URL structure.
  2. Redirect what should not exist. If http:// or the wrong hostname still resolves, send it to the preferred version with a permanent 301 redirect. A redirect beats a tag.
  3. Add a self-referencing canonical to every indexable page. Most CMS plugins do this for you. Check that the URL is absolute, uses HTTPS and has no tracking parameters.
  4. Point variants at the main version. Parameter, filter and print pages carry a canonical to the clean category or product URL. Only do this when the content is the same or near-identical. Pointing a page at a very different one gets ignored.
  5. Use the HTTP header for PDFs and other files that have no <head>.
  6. Keep every signal consistent. The sitemap, internal links, hreflang annotations and canonical tags should all name the same URL. Google warns against giving different canonical URLs for one page through different methods, and against listing HTTP URLs when HTTPS versions exist. See XML sitemaps.
  7. Link internally to the canonical. If your menus link to the parameter version, you are voting for the wrong address.
  8. Verify the tag in the rendered page. Open view-source, search for rel="canonical", and make sure there is one tag, in the head, not injected twice by a theme and a plugin.

How do you measure the result?

Open the URL Inspection tool in Google Search Console and inspect a page. The Page indexing section shows two fields: the user-declared canonical (what your tag says) and the Google-selected canonical (what Google chose). When the two match, your signals worked. When they differ, Google ignored your hint, and the cause is a weaker or conflicting signal, or content that is not really duplicate.

The Page indexing report lists the statuses “Duplicate without user-selected canonical”, “Duplicate, Google chose different canonical than user” and “Alternate page with proper canonical tag”. The first two need attention. The third is normal. The crawl and indexing errors method explains how to work through them.

What mistakes should you avoid?

  • Canonicalizing paginated pages to page one. Page 2 holds different items, so Google treats the hint as wrong. Give each page its own self-referencing canonical.
  • Pointing to a redirected, 404 or noindex URL. The signal dies and Google falls back to its own pick.
  • Relative URLs and missing protocols, which turn into wrong addresses when a staging site gets crawled.
  • Several canonical tags on one page, one from the theme and one from a plugin. Google ignores conflicting tags.
  • Mixing canonical and noindex. The two signals contradict each other.
  • Using the canonical as a cure for thin or similar pages you wrote on purpose. Two different pages competing for one query is a content problem, covered in keyword cannibalization.
  • Treating it as a guarantee. If the signals disagree, Google decides.

Where can you learn more?

The free digital marketing module of the Fe/male Switch startup school covers the technical SEO checks a new site needs. Next steps on SEO100: clean up your redirects, then check your canonical choices in the page indexing report.

Earlier versions of this directory listed this as: Canonical tags, Canonical URL Setup.

Learn SEO as part of building a startup

Fe/male Switch is a startup school and game where you build a real company step by step. Its free digital marketing module covers SEO, and the free startup tools help with the rest.