Published: 19th Dec 2017 | Words: 791 | Reading Time: 4 minutes


Using canonical Meta tags

The canonical tag has in my view become one of the most important head tags you can place in a web page. Search engines can end up indexing multiple versions of the exact same page either through poor coding and structuring on your part or by various other ways through no fault of your own. The canonical link tag is something which you should be using on every page of your site just in case you leave holes in your site structure. It’s a very handy way of telling search engines exactly what page they are on. This is a useful tool when a page is reached from multiple URL’s. The canonical tag can also help stop problems with www and non www pages by specifying the preferred version. // The canonical tag corresponds to the non www version of the page
<link rel="canonical" href=""> // A search spider may land on this page but I am specifying the actual URL
<link rel="canonical" href="">

How canonical tags help with SEO

Most of the problems associated with duplicate content can be attributed to URL parameters by ways of multiple versions of the same page being indexed. When you set up a canonical link tag and set it up properly especially on dynamically generated sites you can tell search engines the exact URL they are on and you give yourself protection from duplicate content issues to a degree. In conjunction with a robots Meta tag you can make it very easy for search engines to crawl your site effectively and index only the pages you want indexed.

Canonical tags and dynamically generated content

The issues that warrant a canonical tag can boil down to how you pages are linked and how you filter data. Here’s a basic example of why on an ecommerce catalogue page a canonical tag is handy for specifying the exact page. // You can probably index this URL as its a unique catalogue page
<link rel="canonical" href=""> // On this URL you would specify the same as it contains the same filtered content
<link rel="canonical" href="">

The href within links back to a page can cause issues if you are linking to a page with parameters that are not validated. If you have a deep folder structure you should be validating each folder level to ensure parts of the URL cannot be manipulated to return the page. While not a perfect solution (validating the parameters is) a canonical tag can help with this issue. In the example below using htaccess rewrites the "1" parameter is passed to a file for validation before grabbing the product info from the database. // Here we have a link to a product page on the site
<link rel="canonical" href=""> // Here part of the URL is changed but may still return the page
<link rel="canonical" href="">

For an e-commerce site you should be dynamically generating a canonical tag just like you would rel tags. For each catalogue page you will want to be generating a canonical tag with the page parameter attached probably. Avoid specifying different canonical tags for pages with sorting or filtering parameters unless you need to. Just specific the base page etc. When combined with the rel tags and meta robots rules you actually give search engines a complete map of your catalogue pages and you index all unique pages and avoid any duplicates.