Your website might be small with fewer pages or big with plenty of webpages. But chances of having duplicate URLs or content can be there. So it’s good to add canonical URL in the source code of your webpage to avoid duplicate URL challenges.
For example, these 4 Home page URLs might seem the same to humans but for search engines, these URLs are different with the same content.
https://www.example.com/
https://example.com/
http://www.example.com/
http://example.com/
So its solution is to leverage a canonical tag, an HTML tag, that highlights the preferred URL like https://www.example.com/ in this case.
What is Canonical URL?
A canonical URL is a preferred URL for any webpage which is considered for indexing and ranking purposes by search engines. A canonical tag, rel=”canonical”, is added within the source code of your webpage which highlights this preferred URL version.
<link rel="canonical" href="https://www.example.com/" />
In February 2009 Google, Yahoo and Microsoft announced support for rel="canonical"
tag as a solution to reduce duplicate content.
Reasons for Duplicate Content
There may be different reasons for having multiple URLs with duplicate content on your website. Here we have three most common reasons for duplicate content:
- Your website server creates ‘http’, ‘https’, ‘www’, ‘non-www’ variants of each URL due to some configuration like:
http://example.com/abc.html
https://example.com/abc.html
http://www.example.com/abc.html
https://www.example.com/abc.html
- Your website has some dynamic URLs with parameters like:
http://example.com/fashion?category=shirts&type=skin-fit
- You have different versions of your website based on devices like desktop and mobile:
https://www.example.com/
https://m.example.com/
Best Practices
Now let’s see some canonical URL best practices that are helpful in preventing duplicate content in your websites.
1. Add Canonical Tag in <head>
The canonical tag rel="canonical"
should be added within <head>
of your webpage as early as possible. If this canonical tag is added in the <body>
part of your webpage then it’s not considered by search engine crawlers.
2. Use Absolute URL in rel="canonical"
Tag
You should always use an absolute URL in rel="canonical"
tag as it should include a complete URL. Avoid using a relative URL that doesn’t include a complete path.
3. Apply 301 Redirect to Canonical URL
You should permanently redirect URLs with duplicate content to the preferred canonical URL. This helps both your users and search engines to reach the webpage with the primary content.
For example in the case of your Home page all the URL variations like https://example.com/,
http://www.example.com/ and http://example.com/should redirect to your preferred URL https://www.example.com/.
4. Add Preferred URL in XML Sitemap
It’s good to add your canonical webpage URLs in your XML sitemap. This helps crawlers to crawl only the preferred URLs instead of duplicate URLs in your website. Adding preferred URL versions in XML sitemaps is more helpful in large websites with plenty of webpages.
5. Add Only Working URL
Remember to add only working URL as canonical URL with primary content in Canonical tag. You should avoid a broken URL with the 4xx status codes or redirected URL with 3xx status codes as canonical URL.
6. Use Canonical Tag Once
Each webpage should have only one canonical tag rel="canonical" in its source code. If your webpage has more than one canonical URL
then none will be considered by search engine crawlers.
7. Add Indexable URL Only
URL which you specify in your webpage’s canonical tag should be indexable which you want to rank in search engines. Any URL which has a noindex robots meta tag must not be considered a canonical URL.
8. Self-referencing Canonical in Pagination
Pagination is when you distribute your content in a series of webpages. This can be due to a long article divided into 2 or more webpages or a list of products shown in series of 2 or more webpages on your website.
You should implement self-referencing canonical URL, with pagination attributes rel=”prev” & rel=”next”, in case of pagination in your website.
<link rel="prev" href="http://www.example.com/products-list/" />
<link rel="next" href="http://www.example.com/products-list/page/3/" />
<link rel="canonical" href="http://www.example.com/products-list/page/2/" />
9. Cross-domain rel="canonical"
Tag
You might have multiple domains where you publish the same article or post for some reason. But you want to rank only one domain for that original content that you have published in your other domains too.
https://www.newsexample.com/original-post.html
https://www.regionalnewsexample.com/copy-original-post.html
In this case, you should leverage the cross-domain rel="canonical"
tag to indicate a specific domain with the original post which needs to be considered for ranking in search engine results.