One Quick OpenCart SEO Tip to Avoid a Duplicate Home Page

Posted by Paul on January 18, 2013

So here's a quick code change that you can do to your OpenCart shop to improve its Search Engine Optimisation.

Generally speaking, Google doesn't like it when exactly the same content is accessible via 2 different URLs. In most web applications there are 2 ways to access pages but one of those ways is hidden using something called "mod_rewrite".

This is fine, as long as Google isn't aware of the URLs that are being hidden, but in OpenCart, by default, one of these links remains on the logo and links back to the home page. Usually if your OpenCart shop is:

www.yourdomain.com

You will also be able to access it via:

www.yourdomain.com/index.php?route=common/home

This would be fine as long as that second link wasn't visible to Google, but by default it is - on the logo.

There are two ways to fix this - one by editing your theme and the other way by editing the "controller". There are pros and cons to each way. Personally I'd edit the controller, which is this file:

/catalog/controller/common/header.php [Line 52]

Find:
$this->data['home'] = $this->url->link('common/home');

Replace it with:
$this->data['home'] = $this->config->get('config_url');

And the problem is solved.

If you'd rather change it in your theme, find this file:
/catalog/view/theme/{yourthemefolder}/template/common/header.tpl 

Find:

Replace it with:

Just to clarify you'll only need to do one of the changes above.

You can check to see if it's worked by refreshing the page and then clicking your logo. You should go to www.yourdomain.com without the extra stuff on the end.

Hope this is useful, feel free to leave comments below!

[Update 30/11/2014]
You can now download this fix as a vQmod:
antropy_duplicate_homepage_fix.xml 

blog comments powered by Disqus