Last Updated on June 3, 2019

Canonicals urls are an essential part of avoiding duplicate content in an ecommerce store, and should be added to all pages and products by default.

However, the Opencart CMS doesn’t include any canonical urls for the Homepage or the Category / Sub-category pages, leading to lots of duplicate content issues, and potentially causing issues in your SEO efforts.

I’m going to show you exactly which canonicals you need, and how to easily insert them into your store using a FREE VQMOD file.

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:


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

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:

<link href="" rel="canonical" />

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:


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

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:


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:


And below it, add the following code:

$this->document->addLink('', '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

How to add category canonical links in opencart

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:

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:


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.

Free Vqmod To Insert Homepage & Category Canonicals

Here is your free SEO loophole, a VQMOD file that automatically inserts the canonical for the homepage url, and your category urls.

Simply like or subscribe to gain access to the file below.

How useful was this post?

Click on a star to rate it!

Average rating 4.6 / 5. Vote count: 54

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

E-commerce SEO expert, with over 10 years of full-time experience analyzing and fixing online shopping websites. Hands-on experience with Shopify, WordPress, Opencart, Magento, and other CMS.
Need SEO help? Email me for more info, at

This Post Has 29 Comments

  1. Hi Matt, good article. But i have found another bug.

    I see opencart demo of a subcategory on this page

    The canonical is correct. But if i delete 25 and i write it
    i can see the same page (duplicate content) and a different canonical.

    It’s possible to solve it? I think that to be sure 100% we need to solve it, right?
    Thanks so much !!!

    1. Hi Antonio, I’ve checked the demo urls you’ve pasted and they both have the same canonical url:

      This means that Google won’t treat them as duplicate content.

      All the best.


  2. Hi Matt,

    Wah thanks it’s worked in opencart v1.7. Many Thanks.

    But when I try in opencart 2.2 it’s not worked. Any suggestion ?


  3. Hello!
    I think about to add in canonical for pagination link to page with all products of current category. Some link like Show all. But, I did not find the way how to do it.
    I thought about something like this
    But I am not sure.
    Maybe you did it or can help me to find better method?
    Thank in advance.

    1. Hi Anna,

      The ideal solution is to set all pagination pages (page 2, 3, etc) to noindex, follow.

      This means that Google will read the content (links to products, etc) but it will not index the pages.

      To do this in Opencart, I think you need to do some custom coding, a temporary solution would be to block the pagination in the robots.txt file such as:

      Disallow: /*&sort
      Disallow: /*&limit
      Disallow: /*?limit=

      But in the long term it’s better to have them crawled but not indexed.

      I’ll have a look for a plugin that works for this and get back to you.

      All the best.


      1. Hi Matt,

        Did you manage to figure out a mod for the category page 2/3/4/5 duplicate tags? at the moment, we have managed to solve these issues in a robots.txt file, however it would be nice to get a permanent fix for the website so it doesn’t see this as a duplicate tag.

        Thanks in advance

        1. Hi David,

          Sorry for the late reply.

          I think realistically it’s ok to index the page 2/3 etc urls as long as you have the correct rel=”next” rel=”prev” tags in place.

          You still want them to crawl the links to product pages, and so you don’t really want to completely block the other pages unless you’re getting the wrong variation ranking in SERPs.

          If you want me to look at your site, then feel free to email me at

  4. Hello will i see a big difference in the ranking?
    I guess i have to get better ranking just by ading this.
    I mean it was even confusing for me the way opencart handles url’s

    1. It’s all relative to how many problems you have, the quality of your site, etc. But I would definitely expect to see a rankings improvement from fixing duplicate content problems on any website.

  5. Hi Matt, im wondering does the opencart have default canonical links implemented already? I think it does, except for the homepage if im not mistaken. Can you confirm this?


  6. Hi;
    Thanks for your great article.
    I have an issue and i hope you would help me.
    I’ve done what did you said and I’ve added codes in my controller in the write place,
    But unfortunately there is no link appearing in my frontend.
    As i know we are adding a Link with out controller to show in frontend but there is no call in header.tpl .
    What should I do ?
    Thanks 🙂

  7. I have add code in my opencart version, But not getting solution, Can you please suggestion.

    1. I think for OC 3.xx it’s done slightly differently.

      Your header.twig file should contain this code:

      {% if canonical %}
      {% endif %}

      Then the line you want to have in your controller (instead of the one mentioned in the article) is this:

      if (isset($this->request->get[‘route’])) {
      $this->document->addLink($this->config->get(‘config_url’), ‘canonical’);

      Let me know if that works! You can always email me at

      1. Thanks for your valuable insights. Using and say your comment about

        {% if canonical %}
        {% endif %}

        should be in the header.twig. Are you saying this needs to be added to the header.twig or should this already be in there. If it needs adding, can you confirm where to place in the twig file and here the twig file is located. Thanks so much.

        1. Hi Kay,

          Thanks for your comment. I said that the {% if canonical %} ..etc code should be in your header.twig already.

          The new code should be added to the controller file called “category.php” found at catalog/controller/product, after this line: $this->document->setDescription($category_info[‘meta_description’]);

          The new code to add is: if (isset($this->request->get[‘route’])) {
          $this->document->addLink($this->config->get(‘config_url’), ‘canonical’);

          Let me know if that works for you.


          1. Hello Matt,
            I don’t find this code in header.twig. where should I add it.

            {% if canonical %}
            {% endif %}

  8. Hi Matt – thanks for this. Will it work with opencart multistores, running on different domains?
    i.e. following your instructions for the home.php, if I put the domain of the installation site there, will it work in the multistores with different domain names?
    First navigate to: catalog/controller/common/ and open the file home.php.
    Next you will want to find the line:
    And below it, add the following code:
    $this->document->addLink(‘’, ‘canonical’);
    Many thanks

    1. Hi Bu, in most situations these will canonical back to the main category page.

      If not, then you can block the URL variations in the robots.txt if they follow a pattern and don’t conflict with other urls.

  9. Hi Matt,

    Thank you for your awesome article! Just wondering if there is a way to check if the page is category or product or else then we can have a canonical tag according to that? So I can just put that code into head.tpl file without having to config each custom code for homepage, about page, category pages and product pages?

  10. Thank you, Finding your post saved all the effort, saved the day.
    I wish you all the good luck. You have quality manners.
    I recommend this for all who use opencart – It works great !


Leave a Reply

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