How And When You Should Use Canonical URLs For Better SEO

April 12th, 2015

Too often ignored or misused, canonical URLs represent a key factor to improve your websites’s SEO and they are actually a very simple technique to understand and deploy.

Basically, canonical URLs tell Google (and other search engines) which is the preferred URL they should index when the same content is served through multiple URLs. This is a very common issue on dynamic websites or online stores. Look at the following examples:

EXAMPLE #1:

http://www.example.com/content.html
http://example.com/content.html

Your server is configured to offer the same content with or without the “www.” subdomain (this is super-common). Generally, it is suggested to use the complete version (with “www.”) as the canonical URL.

EXAMPLE #2:

http://www.example.com/content.html
https://www.example.com/content.html

Your server is configured to offer the same content on HTTPS protocol (for example when the user is logged in). Google suggest to set the HTTPS version as the canonical URL.

EXAMPLE #3:

http://www.example.com/
http://www.example.com/index.html

Your server is configured to offer your default home page with or without its file name. You should use the domain-only version (without file name) as the canonical URL.

EXAMPLE #4:

http://www.example.com/category/post-name
http://www.example.com/category/post-name/

Your server is configured to offer the same content with or without the trailing slash. It’ usually suggested to use the version with trailing slash as the canonical URL.

EXAMPLE #5:

http://www.example.com/dresses/long-red-dress.html
http://www.example.com/dresses/red/long-red-dress.html
http://www.example.com/dresses/long/long-red-dress.html

Dued to dynamic URLs, the same page is reached through different URLs as a result of category browsing.

EXAMPLE #6:

http://www.example.com/cat.php?p=dress&c=red&t=long
http://www.example.com/cat.php?p=dress&t=long&c=red
http://www.example.com/dresses/red/long/

Dued to dynamic URLs, the same product category can be reached through different URLs (e.g., depending on different querystring parameters).

All the above examples would greatly enjoy a correct use of canonical URLs in order to:

  • Consolidate duplicate or similar content on search engines
  • Consolidate tracking metrics for a single product, article or category served through different URLs
  • Defining the URL you want people to see

How To Setup The Canonical URL Attribute

Now, take the example #1 above and suppose you want to set http://www.example.com/content.html to be the prefered URL. The easiest and most effective method to do this is including the following line into the <head> section of that page:

<link rel="canonical" href="http://www.example.com/content.html" />

It’s just that simple. Rememeber to always use absolute paths and not relative paths when declaring canonical URLs. The following line, for example, is wrong:

<link rel="canonical" href="/content.html" />

2 Comments on "How And When You Should Use Canonical URLs For Better SEO"

  1. Jasvinder says:

    URL Canonicalization seems to be quite new topic to me, being a newbie. Although, I have read some guides, but still i have one confusion, Do I need to add URL Canonical Tag in every page of my site?

    • marcello says:

      Hi Jasvinder, basically you should use canonical URLs if your website offers the same page at different URLs. See the examples in my post. But if you are unsure on what you are doing, it’s better not to use this powerful tag.

Leave a Reply to marcello Cancel reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>