Canonical URL

Canonical URL: What it is and How to use it

Canonical URL comes in handy when a single page is accessible by multiple URLs or different pages have very similar content.

Canonical URLs come in handy when a single page is accessible by multiple URLs or different pages have very similar content. Google or any other Search Engine considers these pages as duplicates and if you don’t explicitly tell them which version of the page is the main one, they might choose a URL themselves and crawl the remaining URLs less often.

So how can you tell the search engines to prefer one URL over the others that might have very similar or even the same content? You use an HTML element called canonical URL.


What are Canonical URLs?

Canonical URL

Canonical URLs are HTML elements that help you tell search engines which is the most representative URL out of a set of duplicates on your site or across different sites.

For instance, if you have two URLs for the same page (example.com?dress=1234 and example.com/dresses/1234) you can assign one of them as the main URL. You can tell the search engines that the first version of the page (example.com?dress=1234) is the canonical URL. So from then on, Google will crawl your Canonical URL normally but the canonicalised link (example.com/dresses/1234 in this case) will be crawled less often.

To understand the importance of a Canonical URL, it’s important to first understand how Googlebot or any other search engine bot indexes and chooses the Canonical URL.


How Googlebot indexes and chooses a Canonical URL?

When Googlbot is indexing your site and finds multiple pages with the same content, then it tries to choose a page that it thinks is the most complete and relevant to the user. There are various factors that the Googlebot considers while choosing a Canonical URL, such as, whether the page is being served over HTTP or HTTPS, the page quality, whether the page is submitted in the sitemap and the rel=canonical labelling.

If you don’t explicitly tell Google or the other search engine bots, which URL should be chosen as the Canonical URL, they might choose a URL on their own and this can lead to unwanted behaviour.

As mentioned above, the canonical URL is crawled more often than the other URLs that are considered as duplicates since the search engine crawlers want to reduce the crawl load on your site. So, it’s important to always assign a Canonical URL in such cases.


But wait, Isn’t it bad to have duplicate content?

No, there might be some valid reasons for duplicate content to exist. As mentioned in our Content Syndication post – popular to the contrary belief, there is no such thing as duplicate content penalty.


When is it ok to have similar or duplicate pages?

Google gives a list of various scenarios where it might be ok to have duplicate or similar pages. Keep in mind, the pages don’t have to be exactly identical to be considered duplicates. Simple sorting and filtering of list pages do not make the pages unique.

Here are a few valid reasons why you might have different URLs pointing to the same page or have multiple pages with very similar content:


1. To support multiple devices:

https://example.com/category/blog-post-title
https://m.example.com/category/blog-post-title
https://amp.example.com/category/blog-post-title

Let’s look at a real-life example of this:

RealEstate.com.au is an extremely famous property site in Australia. You can visit the buy property section of the website in two ways:

https://www.realestate.com.au/buy
https://m.realestate.com.au/buy

2. To enable Dynamic URLs for things like Query Parameters:

https://www.example.com/products?category=shoes&color=red
https://www.example.com/shoes/red/redshoes.html

URLs can sometimes contain Query Parameters. Query Parameters are used to define certain content or actions depending on the data being passed.

Let’s look at an example. JBhifi.com.au is an electronics store in Australia. Let’s look at the iPhone collection on their website:

The link below as of 25 Feb 2022 showcases 85 products on the page.

https://www.jbhifi.com.au/collections/mobile-phones/iphones

If I try to sort the products based on Price (Low to High), I get the same 85 products but sorted according to the price. Notice how a query parameter gets added to the end of the URL (sortBy=price_asc)

https://www.jbhifi.com.au/collections/mobile-phones/iphones?page=1&hitsPerPage=36&sortBy=price_asc

In the above example, I get the same page but through two different URLs.


3. If your blog system saves the Multiple URLs as you place one post in multiple categories:

For instance, you are writing a post on the latest iOS software for your tech blog. You can place this post under two categories: Apple and Latest Tech News.

Depending on your permalink structure, your blog can generate two different URLs that lead to the same post:

https://www.yourtechblog.com/apple/iOS15
https://www.yourtechblog.com/latesttechnews/iOS15

4. If your server is configured to serve the same content for www/non-www http/https variants:

http://www.yourtechblog.com/
https://www.yourtechblog.com/
https://yourtechblog.com/

5. If you republish your existing content on other websites (Content Syndication) to reach a broader audience:

❗️ Google has recently updated its guidelines and it no longer recommends the use of canonical tags for syndicated content on other websites. Read more about the update here.

You can learn more about Content Syndication and how to do it properly from our post.

Let’s look at an example from this blog itself. I wrote a post on my blog and then republished the entire thing on Medium.com.

https://www.blog.nimitkapoor.com/deep-dive/6-important-user-behaviour-metrics-you-should-track/

https://medium.com/@nimitkapoorDM/6-important-user-behaviour-metrics-you-should-track-8df0b1736b11

How does a Canonical URL Look?

Before we move on to why you should use Canonical URLs, let’s see how it looks first. Canonical URLs cannot be seen by the visitors on your site, they are only visible to the search engine bots and they can be defined in the page source or HTTP Header.


1. HTTP Header

In the HTTP Header, your Canonical URLs will look something like this:

HTTP/... 200 OK
 
...
Link: <https://example.com/blog>; rel="canonical"

This is the approach to take if you’re putting Canonical URLs for files, such as, PDFs.


2. Page Source / <Head> Section of the site

This should be located in the <head> section of your page code. It looks something like this:

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

If you want to see which approach works for you, Google has a great comparison in this blog post.


Why and When should you use Canonical URLs?

There are many reasons why you should use Canonical URLs. Let’s look at some of them:


1. To specify which URL visitors see on the search engine:

If we consider the same example from above, if you have two URLs that lead to the same page on your website you might want visitors to reach your red shoes product page via https://www.example.com/shoes/red/redshoes.html and not https://www.example.com/products?category=shoes&color=red.


Specifying the Canonical URL helps Google and other search engines to consolidate link signals for duplicate or similar pages to one single URL. For instance, any links from other sites to https://www.example.com/products?category=shoes&color=red gets consolidated with links to https://www.example.com/shoes/red/redshoes.html, which is your preferred URL.


3. To manage syndicated content:

If you syndicate your content to other domains, you will definitely want to add the canonical URL to ensure that your preferred URL appears in search results.

Depending on your requirements, the canonical URL can be the post on your website (if you want that post to get more attention from Google) or the syndicated post on the external domain.


4. To avoid wastage of crawl budget on duplicate pages:

As your website grows, you’ll want Google and other search engines to crawl and index new pages rather than wasting time crawling multiple duplicate pages.


5. Communicate the relationship between the desktop and mobile version of pages:

When you have mobile and desktop versions of your website, it’s important to communicate the relationship between these pages to Google. You do this using Canonical URL and rel=”alternate”.

Let’s look at the above example of Realestate.com.au. If we have a look at the page source of their desktop and mobile sites, we can see how they make use of rel=”canonical” and rel=”alternate”.

Desktop version:

Rel canonical and rel alternate on realestate desktop version

Mobile version:

Rel canonical on realestate mobile version

6. Canonical URL referencing itself:

Even if there is only one version of the page, just ensure that the canonical URL self-references. They are not absolutely necessary but they do help.


How should you add Canonical URLs?

There are various ways in which you can add Canonical URLs to your page. As mentioned above you can manually add it either in the page source or the HTTP Header of your page.

However, if you’re on one of the popular CMS like WordPress, Wix or Shopify, it’s extremely easy to define a canonical URL. Here’s how you can do it on either of these platforms:


How to Add Canonical URL in WordPress?


1. Download and Install the Yoast SEO Plugin

Plugins like Yoast SEO make it extremely easy to edit the canonical URL for any page.

2. Go to the Post/Page that you want to edit the Canonical URL for

From the left-hand navigation of the WordPress Dashboard, find the post or the page that you want to edit the Canonical URL for. Once you’ve found the required post/page, click on Edit.

3. Go the the Advanced Section of Yoast SEO and edit the Canonical URL

Enter the FULL CANONICAL URL, including the https/http and www or non-www.

Canonical URL(In WordPress)

How to Add Canonical URL in Shopify?


1. Install the Yoast SEO app in Shopfy

Yoast SEO has a nice and simple-to-use app for Shopify as well. If you do not want to download the app, then you can edit the Canonical URLs by editing the theme.liquid file. Here’s a guide to help you with that approach.

2. In the Optimize section of the Yoast SEO App, select the page, product, collection etc that you want to edit the Canonical URL of

Yoast SEO in Shopify
Source: Yoast SEO

3. Go to the Advanced section of the Yoast SEO Sidebar and enter the full Canonical URL with the http/https, www or non-www version:

Canonical URL using Yoast SEO in Shopify
Source: Yoast SEO

How to Add Canonical URL in Wix?


1. Go to the Page’s SEO Settings

To do this, click on the Menus and Pages Icon from the sidebar. Then click on the three dots next to the page you want to edit the Canonical URL of and click on SEO Basics.

Opening SEO Basics settings on Wix

2. Edit the Canonical URL

Click on the Advanced SEO tab, go to Additional Tags and edit the canonical URL field.

How to change the canonical URL on Wix

General Guidelines for Canonical URLs

There are few best practices that you should follow while using Canonical URLs:

  1. Use Absolute URLs: This is extremely important. Use the full domain, the HTTP or HTTPS and www or non-www version. There should be no doubt about which link has to be indexed. For instance, use https://www.example.com/post1 instead of /post1 or www.example.com/post1.
  2. Don’t use robots.txt for canonicalization purposes.
  3. Make sure that the canonical URL points to an indexable URL.
  4. There should only be one canonical URL per page. (For instance, don’t specify one canonical URL using the HTTP Header method and another one using the rel=”canonical” method).

💡 Recommended Reading: Non-Canonical Pages in Sitemap – SEO Errors

Nimit Kapoor photo

Nimit Kapoor

Digital Marketer and SEO specialist with 4 years of experience and a passion for helping businesses of all sizes grow their online presence through on-page and technical SEO. Nimit contributes his SEO expertise as a ghostwriter for Ahrefs, aiding fellow professionals in the field. As an independent consultant, he collaborates with small and medium-sized businesses, enabling them to achieve their growth objectives even with limited resources.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *


Search