Business Magazine

Opencart Canonicals & Duplicate Content

Posted on the 09 April 2017 by Matt Jackson @MattJacksonUk1

What is a canonical url and why do you need one?

Simply put, a canonical link points to the "proper url location" of a page, to avoid Google indexing duplicate page urls, and maintain the link equity of your website.

Examples of Duplicate Content in Opencart

There are plenty of examples in Opencart of duplicate content that can harm your websites Google rankings.

For example if you can visit a product via different routes such as:

  • Homepage -> Category -> Product
  • Homepage -> Category -> Sub-category -> Product
  • Homepage -> Product

These urls will all have different url paths:

  • http://domain.com/category/product
  • http://domain.com/category/sub-category/product
  • http://domain.com/product

When Google crawls your website, it follows all of these variations, and so each of these links will be crawled, and counted as a different page.

Duplicate Content And Google Panda Penalties

Opencart Canonicals & Duplicate Content

Google HATES duplicate content with a passion, particularly duplicate content on the same website.

They have an algorithm dedicated to penalising websites for this, called Panda, which is notorious for not just harming the pages with duplicate content, but bringing the entire websites rankings down.

Fix Duplicates with a Canonical Link

Luckily there is a fantastic way to tell Google that each of these pages are the same, and then tell them which one you would like to count as the "proper location".

That's called a canonical link, and it looks like this:

In our example, if this was added to the product page as a canonical link, then it tells Google that the Homepage -> Product version of this url is the only one that should be indexed.

This fixes the duplicate content, as Google only indexes one version of the page, keeping all of your indexed content unique, and resulting in higher rankings.

Stop Losing Link Equity With Canonicals

Canonicals also prevent you from spreading your link equity too thinly over your website. For example if someone links to these two pages:

  • http://domain.com/product
  • http://domain.com/category/product

Then without a canonical url, you will have one link to each page, and two competing pages that can cause keyword cannibalisation.

With a canonical url, the link pointing to the non-canonical version of the page will be counted towards the rankings of your main page, helping it rank even better in Google for its target keywords.

How to Add a Canonical Link to Your Opencart Homepage

Opencart Canonicals & Duplicate Content

The homepage of your online store is the single most important page from an SEO perspective.

It will normally have the greatest amount of inbound links, and contain internal links to your other most important pages, spreading the authority to the rest of your website.

So what's the problem?

Without a canonical, multiple variations of the homepage url can be indexed in Google, urls such as:

  • http://domain.com
  • http://domain.com/index.php
  • http://domain.com?test=1234
  • http://domain.com?product=category

These will all display the same page (your homepage), but because they are separate urls Google treats them as unique pages.

The Code To Add a Homepage Canonical in Opencart

You will need to edit one of your website files via FTP or file manager to do this. Alternatively for a better way to implement it, you can use the FREE VQMOD file at the end of this guide.

First navigate to: catalog/controller/common/ and open the file home.php.

Next you will want to find the line:

$this->document->setDescription($this->config->get('config_meta_description'));

And below it, add the following code:

$this->document->addLink('http://YOURDOMAIN.com/', 'canonical');

You will need to replace the example url with the homepage url of your Opencart store.

How to Add a Canonical Link to Your Opencart Category Pages

Opencart Canonicals & Duplicate Content

As mentioned above, your category pages require canonicals to ensure no duplicate paths are indexed, and to maintain your link equity.

This is a particular problem with category pages that contain product filters, as they often create new urls when you choose a filter.

For example when you filter the product list by Price Low > High in Opencart the url looks like this:

http://opencart.matt-jackson.com/desktops?sort=p.price&order=ASC

Without a canonical, this will index as a new url, and cause a Google Panda penalty from duplicate content as mentioned previously

The Code for an Opencart Category Canonical

It's quite simple to add this code to the category controller, and produce your own category canonical links. HOWEVER, if you would rather have the simple and FREE version of doing it, see the free VQMOD file attached at the end of this post.

Via FTP, visit this location in your store: catalog/controller/product/ and open the file category.php.

Find the following line of code:

$this->document->setDescription($category_info['meta_description']);

And below it add this code:

$this->document->addLink($this->url->link('product/category', "path=".$this->request->get['path']), 'canonical');

This will produce the canonicals on every category and sub-category page.


Back to Featured Articles on Logo Paperblog