DEV Community

Cover image for A Quick Guide Through Canonical Links
Marc Backes
Marc Backes

Posted on • Originally published at

A Quick Guide Through Canonical Links

The problem ๐Ÿง

Duplication within your own domain

Let's assume you have a page on your website that has the identical content as another page, for example:


This would be bad, because the search engines would not know which one is the "real" link, which one should be indexed in their engine. This results in that page being "punished" by ranking it down.

Cross-domain duplication

The same happens if you say, have a blog where you passionately share your content, and post the same content on another blog to enhance the reach of your knowledge:


This would cause your website being ranked down, because there is another site with the same content as yours.

This is where canonical links come in.

The solution ๐Ÿ’ก

A canonical URL is the "preferred" or even "original" page of your content. To include it in your website, you set a <link>-tag with rel=canonical in the <head>-part of your HTML as such:

<link rel="canonical" href="" />
Enter fullscreen mode Exit fullscreen mode

This way we tell the search engines that is the original content origin.

It works similar to a HTTP 301 header (moved permanently), just that the website is not actually being redirected.


You might ask yourself if it's necessary to set a canonical link to your page, even if you only have the content on a single page and are not referencing any third-party content.

Yes, it is highly recommended to have canonical URLs in every page of your website. The reason for this is, that if you share social media campaigns with links such as or, it is a different URL with the same content. As we learned, this gets your page ranked down by search engines.

Common mistakes

The 5 most common mistakes when dealing with canonical links, according to Google are the following:

  • Setting canonical URLs for paginated sites
  • Using relative URLs instead of absolute ones
  • Multiple declarations of rel=canonical
  • Category or landing page specifies rel=canonical to a featured article
  • rel=canonical in the <body> element

Read more about these mistakes on Google's Webmaster Central blog.

Photo by kaleb tapp on Unsplash

Top comments (0)