This is the first in a series of posts designed to help improve the Web developer’s understanding of key SEO factors. The goal? To eliminate the need for so much back and forth between the SEO and the development team.

Whether you’re familiar with the phrase “Canonical URL” or if you’ve never heard it before, it’s essential everyone on your team understands its importance and the role it plays in the optimization of a website. If you’re not familiar with the term, simply put, a canonical URL is the authoritatively correct URL for a resource. To help illustrate this point, let’s say each of the following URLs is a means to access the homepage of your site:

  • http://www.yoursite.com/
  • http://yoursite.com/
  • http://www.yoursite.com
  • http://yoursite.com
  • http://www.yoursite.com/index.html
  • http://yoursite.com/index.html

While the average person may recognize these URLs as the same, from a technical search engine standpoint, they are not. A web server sees these six unique URLs as six unique pages. If they’re all crawlable, they’ll all be indexed.

In most cases, however, different content doesn’t exist on each of these variations, and without Google “canonicalizing” a URL, or selecting one URL best representative of the set to return in results, all could very easily be viewed as duplicated content by the engines. This is bad. To make sure the search engines are indexing the correct page, you need to select which variation of the URL you’ll want to set as canonical.

In truth, it doesn’t matter which URL you deem as the canonical URL. In most cases, it’s simply a matter of preference. For example, if you already have specific marketing materials printed using a particular instance of the URL, I’d recommend going with that to avoid confusion. Or if most of the links coming into your site point to the www-version, it may be easier to stick with that one. However, most people will prefer the non-www version, sans trailing slash. (http://yoursite.com).

What’s less important is which version of your URL you select. What’s more important is that you pick one and stick to it.[Tweet This]

Once we’ve determined which URL we want to set as canonical, it’s time to start building up that authority. The first thing we’ll need to do is make sure that every single variation of the URL is redirected to the canonical by way of a 301 Redirect.

Next, make sure you’ve specified the Canonical URL tag in your HTML header. This is another way to tell the search engines what the canonical URL of any given page on our site should be. While this is especially handy for pages using session IDs or other dynamic URL parameters, it is good practice to use this on all pages of a site. Let’s put this to use in a few examples:

On our homepage, it’s quite simple really:

<link rel="canonical" href="http://yoursite.com/" />

Same goes for directories and pages on your domain as well:

<link rel="canonical" href="http://yoursite.com/directory/ " />
<link rel="canonical" href="http://yoursite.com/directory/page" />

Regarding pages using dynamic URL parameters – there are several different ways these can be handled depending on the type of URL we’re dealing with.

Tracking URLs will typically contain some form of dynamic tracking number appended to the URL, as follows:

  • http://yoursite.com/page?session=1234

When we have any instance of tracking parameters, the canonical URL should be determined by stripping out the parameter. In this case, we’d be left with the following for our tag:

<link rel="canonical" href="http://yoursite.com/page" />

Another example worth covering is the instance of dynamic URLs. As an example, take these URLs which in this example all go to the same blog post:

  • http://yoursite.com/blog/1234
  • http://yoursite.com/blog.php?id=1234
  • http://yoursite.com/blog.php?id=1234&comments=on

Now in this example it isn’t simply a matter of stripping out the parameter. We never want to set the canonical URL of specific posts to the main blog page. From an SEO perspective, the right and proper thing to do would be to eliminate the use of dynamic URLs for blog posts all together. Having keyword-rich static URLs will get the most value:

http://yoursite.com/blog/keyword-rich-post-title

The Canonical Tag would look like this:

<link rel="canonical" href=" http://yoursite.com/blog/keyword-rich-post-title" />

And of course, whenever you modify URLs, make sure you’re properly redirecting the old addresses with 301s.

Similar to the last example is product pages, where we could have countless variations of the same content via URLs using a wide range of parameters. Having a static URL for each product in your catalog and using that as the canonical for every dynamic variation is surely the best way to go.

As you establish canonical URLs across your site, you need to remember that your internal links are one of the most important canonical signals. It is critical that all of your links are pointing to the URLs that you’ve labeled as canonical in the head tags. Otherwise, you’re giving the search engines mixed messages which could cost you rankings.

Hopefully this helps you some. If I failed to mention anything of note, or if there is a topic you’d love to see covered in some detail on the blog, please feel free to let me know in the comments. As for my next post in the series, I plan on staying the course and delving into the fantastic world of the Robots.txt file. Trust me, it’ll be some real riveting stuff.