SEO – Canonical URLs
One page can open with more than one address. For example http://example.com/shoes, https://example.com/shoes, https://www.example.com/shoes/ and https://example.com/shoes?utm_source=mail. For a visitor it is the same page, but for a search engine these are different URLs with the same content (duplicate content).
The canonical URL is the preferred address which you want search engines to index and show. The canonical tag is a way to tell it.
How to add a canonical tag
Put it inside the <head> of the page, with the full address of the preferred version:
<link rel="canonical" href="https://example.com/shoes/">
Every page should have a canonical tag which points to itself (a self referencing canonical). Then, if some other version of the page appears, it points back to the correct one.
When do duplicate pages happen?
- With and without
www,httpandhttps, with and without a trailing slash. - URL parameters for tracking, sorting and filters:
?utm_source=,?sort=price. - Print versions or separate mobile versions of a page.
- The same article published in more than one category.
- Content syndicated (copied with permission) on another website.
Example: a page with parameters
<!-- This page: https://example.com/shoes/?sort=price -->
<head>
<link rel="canonical" href="https://example.com/shoes/">
</head>
Canonical for another website
If you publish the same article on another website, ask them to add a canonical tag which points to your original article. A link back is also fine.
<link rel="canonical" href="https://original-site.com/my-article/">
Canonical in the HTTP header
For files which have no HTML head, like PDF files, you can send the canonical in the HTTP header:
Link: <https://example.com/guide.pdf>; rel="canonical"
Important points
- A canonical tag is a hint, not a command. Google can choose a different URL if other signals say so.
- Use only absolute URLs (with https and the domain).
- Point to a page which works (status 200), not to a redirect or a 404 page.
- Do not put a canonical tag and a
noindexon the same page. They give opposite messages. - Use one canonical per page, in the head, and do not change it with JavaScript if you can avoid it.
- For paginated pages (page 2, page 3), each page should have its own self canonical, not the first page.
Canonical or 301 redirect?
If the old URL is not needed at all, use a 301 redirect. Visitors go to the new address, and the old one disappears. Use a canonical tag when both pages must stay open for visitors, like a filtered list.
How to check
- In your browser, right click, View page source, and search for
canonical. - In Google Search Console, the URL Inspection tool shows the user declared canonical and the Google selected canonical.