Canonical Tags Explained: How to Fix Duplicate Content Issues

Mirsal Saidu Updated 8 min read

Canonical tags tell Google which URL to index when one page has several addresses. Real examples, canonical vs 301, common mistakes and how to check yours.

Canonical Tags Explained: How to Fix Duplicate Content Issues

What is a canonical tag in SEO?

A canonical tag is a <link rel="canonical"> element in a page's head that names the URL you want search engines to treat as the main version when the same content is reachable at several addresses. Google uses it to group the duplicates and consolidate their signals onto one URL. It is a strong signal, and Google can still overrule it: the canonicalization guide says a canonical preference "is a hint, not a rule".

Why I put a canonical on every page

Years ago I worked on a site that had about 5,000 duplicate URLs created by tracking parameters such as ?source=fb. Google ranked the wrong versions of some pages and stopped ranking others. We fixed it in one afternoon with canonical tags. My rule of thumb since then is a self-referencing canonical on every page, so each page names its own clean URL. Google doesn't require it, but it costs one line of HTML and settles the question before tracking links, filters and sorted views start producing copies.

What the tag looks like

On a shop's running-shoe category, all of these addresses can show the same products:

https://example.com/shoes/running
https://example.com/shoes/running?sort=price
https://example.com/shoes/running?utm_source=newsletter
http://www.example.com/shoes/running

Every version carries the same line in its <head>, with an absolute URL:

<link rel="canonical" href="https://example.com/shoes/running">

The Basic SEO tab of the Meta Tag Generator has a Canonical URL field that writes this line for you, and it reuses the same address for og:url if you leave the OG URL box empty. This blog works the same way: open this article with a tracking parameter on the end and the page still declares the plain /blog/canonical-tags-seo-explained address.

Files without an HTML head, such as PDFs, can send the canonical as an HTTP response header instead. Google supports this for web search results:

Link: <https://example.com/guides/shoe-size-chart.pdf>; rel="canonical"

What is a canonical URL?

The canonical URL is the address Google picks as the representative of a group of duplicate pages. Google's canonicalization guide defines it as "the URL of a page that Google chose as the most representative from a set of duplicate pages." The canonical page is crawled most regularly, and the duplicates less often.

That gives you two canonicals to keep apart. The one in your tag is the canonical you declare. The one Google ends up using is the canonical it selects, and URL Inspection in Search Console shows both. Most of the time they match. When they don't, one of the other signals, such as a redirect, a sitemap entry or your internal links, usually points somewhere else.

People also call the tag a "canonical link" or a "meta canonical". Both mean the same <link rel="canonical"> element; it is a link element, not a meta tag, which is why it uses href rather than content.

Four ways to signal the preferred URL

MethodHow Google describes itUse it when
301 or 308 redirectA strong signal that the redirect target should become canonicalThe old URL no longer needs to work
rel="canonical" link elementA strong signal that the named URL should become canonicalThe duplicates have to stay reachable (parameters, sorted views, a product in two categories)
rel="canonical" HTTP headerThe same annotation, sent with the response; supported for web search onlyNon-HTML files such as PDFs
Sitemap entryA weak signal for the URLs it listsAlways, as a backup; list only canonical URLs

The descriptions come from Google's guide to consolidating duplicate URLs. Whatever mix you use, the methods have to agree, because Google warns against naming different canonical URLs for one page through different techniques. If you build your sitemap with the XML Sitemap Generator, feed it the clean URLs only.

Is duplicate content bad for SEO?

Usually not. Google's canonicalization guide says "some duplicate content on a site is normal and it's not a violation of Google's spam policies." There's no penalty for a product that appears under two categories or a page that loads with and without a tracking parameter.

The cost is practical. Google lists the usual sources of duplicates:

  • Region variants, such as separate US and UK pages in the same language.
  • Device variants, such as a separate mobile version of a page.
  • Protocol variants: the http and https versions of a site.
  • Site functions, such as sorted and filtered views of a category.
  • Accidental variants, such as a demo copy of the site left open to crawlers.

When several of these exist, links and other signals get split between addresses, Google spends crawl time on copies, and your reports show the same page under several URLs. Google may also show the version you like least, such as the one with ?sort=price. A canonical tag tells it which one you'd rather see. Duplicate pages often share duplicate titles too, which makes them harder to tell apart in results; how to write title tags covers fixing those.

When to use a canonical vs a 301 redirect

  • Use a 301 redirect when a page has moved for good and nobody needs the old address, for example after you rename a slug or move the site to https.
  • Use a canonical tag when both URLs have to keep working, like a product page listed under two categories, but only one should appear in search.

Temporary redirects behave differently. Google's redirects documentation says a 302 or 307 is not used as a signal that the target should be canonical, and search results show the source page. Keep 302 for moves that really are temporary. The Redirect Checker lists the status code of every hop, which is how you catch a CMS that issued a 302 when you asked for a permanent move.

Common canonical mistakes

  • Relative URLs. Google asks for absolute URLs in the link element, so write https://example.com/shoes/running rather than /shoes/running.
  • The tag outside the head. Google only accepts the link element when it appears in the <head>; some page builders place it lower down.
  • Signals that disagree. A sitemap that lists the parameter URL while the page names the clean one, or a header and a link element pointing to different addresses. Google calls using both the header and the element at once "more error prone".
  • Blocking duplicates in robots.txt. Google says not to use robots.txt for canonicalization. A blocked URL can't be crawled, so its canonical tag is never read. Robots.txt controls crawling, not indexing; our robots.txt guide for AI crawlers shows how its rules work.
  • Using noindex to choose between duplicates on your own site. Google doesn't recommend it; the canonical tag is the tool for that job.
  • Pointing every paginated page at page 1. Google's pagination guidance says not to use the first page as the canonical and to give each page its own canonical URL.
  • A canonical that redirects or errors. Point it at the final URL, the one that loads directly with a 200 status.
  • A URL fragment as the canonical, such as https://example.com/guide#part-2. Google generally doesn't support fragments, so name the page URL without the # part.
  • JavaScript that rewrites the tag. Google's advice is to set the canonical in the HTML source and make sure scripts don't change it.
  • Internal links to the duplicates. If your menus link to ?sort=price while the tag names the clean URL, the signals disagree. Link to the canonical URL throughout the site.

How to check which canonical a page declares

  1. Paste the URL into the OG Checker. The Detected Meta Tags table has a canonical row next to the title, description and Open Graph tags, and the warnings list notes when a page has none. Compare the canonical row with og:url while you are there: Meta treats og:url as the page's canonical URL for shares, so the two should match (see Open Graph tags explained).
  2. Run the same URL through the Redirect Checker. Each hop shows its status code, and Show headers reveals a Link canonical header if the server sends one.
  3. In Google Search Console, open URL Inspection for the page. It shows the canonical Google selected alongside the one you declared. When they differ, Google's troubleshooting guide names CMS plugins that set the wrong canonical as one common cause.

Frequently asked questions

Where does the canonical tag go?

In the <head> section of the HTML. Google only accepts the rel="canonical" link element there, not in the <body>.

Do I need a canonical tag on every page?

Google says none of the canonical methods are required and it will pick a version itself if you don't. Its best practices do list a self-referential canonical, a tag on the canonical page naming its own URL, so adding one everywhere is a cheap default.

What is a canonical tag example for an http and www site?

If http://www.example.com/page and https://example.com/page show the same thing, put the same line on both: a link element with rel="canonical" and the href https://example.com/page. Better still, 301-redirect the http and www versions to that address and keep the tag as a backup.

Can I canonical to a different domain?

Yes. The standard that defines rel="canonical" (RFC 6596) allows the canonical URL to be on another domain. For syndicated articles, though, Google's troubleshooting guide says the canonical link element is not recommended for avoiding duplication by syndication partners, because the pages are often very different. Its advice is for partners to block indexing of the syndicated copy.

Does Google always follow my canonical tag?

No. Google treats it as a hint and may choose a different page, for example when redirects, the sitemap or the https version of the site point to another URL. URL Inspection shows which one it picked.

Should og:url match the canonical URL?

Yes. Meta's sharing documentation describes og:url as the canonical URL for the page and says likes and shares aggregate at that URL. Using the same address in both keeps search engines and social platforms pointed at one page.


Share this article:
Mirsal Saidu

Mirsal Saidu

Digital & Performance Marketer