Learn about what canonical URLs are and how they affect your SEO
What is a Canonical URL?
A canonical URL is an HTML link element that tells the search engines what your preferred webpage URL structure is for a given page. Canonical URLs are important for your SEO. Google and other search engines crawl your website, and the canonical URL tells them what URL to index individual pages under.
The canonical link element sits inside the <head>
element of your webpage, and has the attribute rel="canonical"
.
Consider the following URLs:
techstacker.com
www.techstacker.com
https://techstacker.com
https://www.techstacker.com
Notice that all the links above lead to the URLs above lead to the same destination, but they’re structured differently. Preferably, search engines should only index your website by using one of the URL structures above.
Canonical links are used to enforce a consistent URL structure to prevent confusing both search engines and people — and hurting your SEO.
So which of the 3 URL structure options above is best for your SEO?
It’s hard to say which URL structure is definitively the best, however, I’ve chosen to not include www
because it makes my URLs look shorter.
If we’re to appeal to authority a little bit, it’s worth noting that top SEO platforms like Yoast and Banklinko don’t include www
in their URLs — for what it’s worth.
That said, I’ve seen no clear evidence that this is better or worse for your SEO.
It’s up to you!
Use canonical links to avoid duplicate content
As a website grows bigger, the risk of duplicate content rises. Duplicate content is identical content that is available on multiple URLs.
Duplicate content is bad for your SEO. If for example, you have a product that appears under multiple product categories on your website, like this:
https://yourstore.com/green-grapes/green-blue-grapes-mix
https://yourstore.com/blue-grapes/green-blue-grapes-mix
By using a canonical URL you can tell Google and other search engines which of those URLs above should be shown in the search results. If someone searches for “green and blue grape mix”, it doesn’t matter to them which of the URLs above they are taken to, as the product item page is the same.
Therefore you should pick one of those URLs for the search engines to index and show on the SERPs (Search Engine Results Pages).
If you don’t use one canonical URL in an example like the above, you can hurt your SEO ranking, because the search engines don’t know which one to show. Having two URLs that lead to the same product indexed by search engines is spreading your SEO points for that product thin. All the points should go to one of those URLs (your canonical URL) to boost your SEO ranking for that particular product.
How to detect canonical URLs
If a page has a canonical URL you can always find it by looking up the source of the webpage. Right-click on any page and click View Page Source and then search for “canonical” (Quick search: CMD + F or CTRL + F).
Don’t assume that your website has canonical URLs. I’ve made the mistake before of assuming that a framework or CMS had canonical URLs handled out of the box, but didn’t. If your website does have canonical URLs, make sure it has the URL structure that you want.