Canonical URL tags - what are they?
Since the widespread adoption and support by all the major search engines dating back to 2008, canonical url tag have been one of the most important improvements to the way you can improve your site's SEO.
A canonical URL allows you to instruct search engines such as Google, Bing, Yahoo and other interested services such as Snapppt, Pinterest or Facebook, that certain similar URLs are actually one and the same. For instance, it is very common to have a product on your website that can be accessed through multiple urls.
An illustrated example
Let's say we have a fictional store that sells Shoes.
Our store could have all the following urls that relate to the same one item - Red Fancy Shoes.
In some cases, the same item could even be available on multiple domain names. So if our fictional store is localised to multiple languages such as English, Spanish and Japanese, we could also have the following typical urls for the same item:
By using a Canonical url tag, we can consolidate all these duplicate URLs into a single master product page url for Fancy Shoes. For this example, the master Red Fancy Shoes product page is: https://www.my.store/products/fancy-shoes
So we would add a canonical url tag to the product page that looks like this:
<link rel="canonical" href="https://www.my.store/products/fancy-shoes" />
NOTE: The URL in the canonical tag will be different for each product or page on your website. As such, it is usually built into your website theme automatically.
What if my website does not have canonical URL tags?
If the canonical tag is missing from your current theme, you should speak to your theme creator or website host who will be able to advise on how best to add it into your theme.
If you are comfortable making the changes yourself, below are some code snippets you can use to add the Canonical URL tag to your website theme, based on who your hosting provider is.
Note: These code snippets needs to be add within the head of your site's theme template:
<html>
<head>
...
<link rel="canonical" href="URL-GOES-HERE" />
...
</head>
</html>```
If you are on Shopify:
you can fix this simply by copying and pasting the following piece of code between the <head>
and </head>
tag in your index
liquid file.
<link rel="canonical" href="{{ canonical_url }}" />
If you are on Wordpress:
You can follow these easy steps to get canonical URLS into your Wordpress theme.
Login to WordPress
Hover over Appearance
Click Editor
Find Theme Header file
header.php
Add the following PHP Code snippet for Canonical URLS within the HEAD section of your theme header file.
<link rel="canonical" href="https://YOUR-DOMAIN-NAME.COM<?php echo $_SERVER['REQUEST_URI'];?>">
NOTE: Make sure you replaceYOUR-DOMAIN-NAME.COM
in the code above with your actual website's domain name.
Alternatively, if this is too complicated, I would recommend using a plugin like Yoast SEO or any other reputable SEO plugin from the Wordpress plugin directory.
Further reading
Consolidate duplicate URLs by Google
Specify your canonical by Google