What is a Canonical URL?
A canonical URL is a special tag that goes inside a web page's HTML code. It allows webmasters to show search engines which URL is the main or preferred version of a page.
A canonical URL is especially useful when the same content can be accessed through various URLs on a website.
If different page links show the same or very similar products or information, a canonical tag indicates which URL is the definitive version that search engines should prioritize.
For example, an e-commerce store may have a laptop product available via different URLs like:
https://www.example.com/product.php?item=laptop&color=black
https://www.example.com/products/black-laptop
https://www.example.com/items/laptop?color=black
Each URL shows the same product, thus leading to duplicate content.
Now you will use a canonical tag to tell search engines which URL is the primary one.
Let's say you select https://www.example.com/products/black-laptop as the canonical URL.
You can then include a canonical link element in the head section of the HTML of the other two pages, like this:
<link rel="canonical" href="https://www.example.com/products/black-laptop" />
This tells search engines that the primary or canonical page for this content is https://www.example.com/products/black-laptop, and it should be treated as the primary source of the content.
To better understand canonical URLs, make sure to read our related post about Canonical Tags.