Canonical link element

The rel=canonical element, often called the “canonical link,” is an HTML element that helps webmasters prevent duplicate content issues. It does so by specifying the “canonical URL,” the “preferred” version of a web page. Most of the time, this is the source URL. Using canonical URLs improves your site’s SEO.

The idea is simple: If you have several versions of the same content, you pick one “canonical” version and point the search engines at it. Adding the canonical element to a URL tells search engines that’s the one they should show in their results.

For example, the canonical URL for our WordPress SEO article looks like this:

<link rel="canonical" href="https://yoast.com/wordpress-seo/" />

A canonical URL can be seen in the source of a webpage, by searching for rel="canonical". It is an element only the search engines see, your users won’t be affected by it.

The SEO benefit of rel=canonical

The history of rel=canonical

The canonical link element was introduced by Google, Bing, and Yahoo! in February 2009. If you’re interested in its history, we recommend Matt Cutts’ post from 2009. This post gives you some background and links to different interesting articles. Or watch the video of Matt introducing the canonical link element. Because, although the idea is simple, the specifics of using it are often a bit more complex.

As we mentioned above, a canonical URL is a technical solution for managing duplicate content. Duplicate content can be a big problem for SEO. When search engines find two (or more) very similar pages, they don’t know which one to add to the search results. As a result, all of those pages might end up ranking lower.

You might, for instance, have a post or product that is attached to two categories and exists under two URLs, like so:

https://example.com/black-shoes/black-and-red-shoes/
https://example.com/red-shoes/black-and-red-shoes/

If these URLs are both for the same product, setting one as the canonical URL tells search engines which one to show in the search results.

You can also use canonicals to point search engines to the original version of an article. For instance if you’ve written a guest post for another website. If you want to post it on your site too, you could agree to post it with a canonical link to the original version.

The process of canonicalization

When you have several choices for a product’s URL, canonicalization is the process of picking one of them. Luckily, it will be obvious in many cases: one URL will be a better choice than others. But in some cases, it might not be as obvious. This is nothing to worry about. Even then, it’s still pretty simple: pick one! Not canonicalizing your URLs is always worse than canonicalizing your URLs.

How to set canonical URLs

Ironic side note

The term ‘Canonical’ comes from the Roman Catholic tradition, where a list of sacred books was created and accepted as genuine and named the canonical Gospels of the New Testament. The irony is it took the Roman Catholic church about 300 years and numerous fights to come up with the canonical list, and they eventually chose four versions of the same story…

Let’s assume you have two versions of the same page, each with exactly – 100% – the same content. The only difference is that they’re in separate sections of your site. And because of that, the background color and the active menu item are different – but that’s it. Both versions have been linked from other sites, so the content itself is clearly valuable. So which version should search engines show in results?

The situation described above occurs pretty often, especially in a lot of e-commerce systems. A product can have several different URLs depending on how you got there. But this is precisely what rel=canonical was invented for. In this case, you would apply rel=canonical as follows:

1. Select which page will get the canonical tag

Say, for example, you have these two URLS, both showing identical content:

https://example.com/wordpress/seo-plugin/
https://example.com/wordpress/plugins/seo/

Pick one of your two pages as the canonical version. This should be the version you think is the most important. If you don’t care, pick the one with the most links or visitors. When all these factors are equal, flip a coin. You need to choose.

2. Add the rel=canonical element

The next step is to add a rel=canonical link from the non-canonical page to the canonical one. Doing that manually means adding rel=canonical as a meta tag in the HTML header of the non-canonical page. You can also use the Yoast SEO plugin to add it for you (see below for more about that).

So, if we picked the shortest URL as our canonical URL, the other URL would link to the shortest URL in the <head> section of the page – like this:

<link rel="canonical" href="https://example.com/wordpress/seo-plugin/" />

It’s as easy as that! Nothing more, nothing less.

What this does is “merge” the two pages into one from a search engine’s perspective. It’s a “soft redirect” without actually redirecting the user. Links to both URLs now count as the single, canonical version of the URL.