Post by mijomedia » Sat Jun 14, 2014 9:32 pm

Hello all,

In this tutorial i will show you how to put the meta tag <meta name="robots" content="noindex,follow"> on specific pages in OpenCart.

Q.A:

Why would i do this?

Out of the box is OpenCart pretty SEO-friendly, but you can always do this better with some tricks and fixes. This will put the meta tag on specific pages such as onsite search results. This is crucial for SEO purposes to avoid certain stuff like duplicate content and low quality pages. If you do not do this it can result bad SEO and in worst cases you can get penalized for bad content.

Why not use /disallow in robots.txt?

I have seen lost of posts in this forum on this case of problem, the thing is that the robots.txt do not "unindex" your pages and many of the search engines do ignore this file. And Google has announced that noindex,follow meta tag is the code you need.



The Tutorial:

To make this happen you need to code some in the core files. You can also make this with a VqMod file if you're not comfort with coding inside the core files.

Lets get going.


Find this file:

catalog/controller/common/header.php
Find line:

Code: Select all

$this->data['links'] = $this->document->getLinks();
After put this line:

Code: Select all

$this->data['robots'] = $this->document->getRobots();

system/library/document.php
Find line:

Code: Select all

private $description;
Above put this line:

Code: Select all

private $robots;
In same file you need to find this line:

Code: Select all

public function setDescription($description) {
Above put this line:

Code: Select all

public function setRobots($robots) {
		$this->robots = $robots;
	}
	public function getRobots() {
		return $this->robots;
	}

catalog/view/theme/YOUR_THEME/template/common/header.tpl
Find line:

Code: Select all

<?php if ($description) { ?>
<meta name="description" content="<?php echo $description; ?>" />
<?php } ?>
After put this line:

Code: Select all

<?php if ($robots) { ?>
<meta name="robots" content="<?php echo $robots; ?>" />
<?php } ?>
We have now done so the controller can put the meta tag on the pages we want them to have. What we need to do next is to define which pages to have this nice little bit of code.

This will be an example to put noindex,follow on search page.

Find this file:

catalog/controller/product/search.php
Find:

Code: Select all

$this->load->model('catalog/category');
After put this line:

Code: Select all

$this->document->setRobots('noindex,follow');
And there you have it. As i said before you can do this with VqMod. I don't know how to attach files on this forum, otherwise i would do it for you with some more pages to have this.

Hope this will help some people that want to tweak OpenCart even more in SEO purposes. Please check out the extension parts of this. Cause i am in work to make a real module for this.

/Mijo Media

Webbutveckling, Sökmotoroptimering, E-handel, Mobilskal, Tillbehör för surfplattor och tillbehör för mobiler


User avatar
New member

Posts

Joined
Fri May 17, 2013 7:54 am

Post by misscaprice » Tue Jul 08, 2014 8:09 pm

Awesome little modification. The author was kind enough to help me with this and I've already got it installed on my site. It works like a charm.

As Search engines become smarter and more picky than before, it's extremely important that your site is sculpted the right way to avoid duplicate content ;)
Thanks again

New member

Posts

Joined
Sat Jan 22, 2011 6:47 pm

Post by Cue4cheap » Wed Jul 09, 2014 7:06 am

I'm always interested in SEO since I am in a pretty competitive product market so I need to ask: Does this actually help?

Also if it does help, would it also help to do that if a sites uses the "Category" module in the column?
Reason I ask, is if you use the links in the header and use the Category module, you will in effect double the links on your page. Most SEO things say to have 100 or less links on your page BUT still others say that is an old "don't do" rule and is outdated.

Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by bunny Chinh » Mon Aug 11, 2014 11:49 pm

Hi,

I completed the features - "noindex, nofollow" or "index, follow" meta tag on specific product pages . It's work very smooth.

Features:
- A product doesn’t perfect about contents, images..., you don't want it's shown on search tools as google, yahoo, bing... Let use “no index” – You will use this fuction to turn on the attribute in admin.

You can get more detail as link:
http://www.opencart.com/index.php?route ... n_id=18262

Newbie

Posts

Joined
Thu Jun 12, 2014 10:54 am

Post by mkp007 » Mon Jan 11, 2016 2:10 pm

Very cool. Thank you.

I had a bit of a hard time adding to https://www.site.com/account/return/insert page?

But here is what you need to look for on this file catalog/controller/account/return.php

Code: Select all

public function insert() {
		$this->language->load('account/return');

		$this->load->model('account/return');
And then add this line after:

Code: Select all

$this->document->setRobots('noindex,follow');
thx

Vorticy, Inc.
Opencart 1.5.6.4, MySQL 5.1.73-5, PHP 5.3.3-46, Plesk v12.0.18, OS CentOS 6


New member

Posts

Joined
Fri May 10, 2013 12:56 am

Post by fewleh » Tue Mar 29, 2016 6:20 pm

Hey.. nice extension. I have a Q though.. is it possible to go one step further?

I.e. <if product is in 'cat id' then add noindex tag> ?

Product 1, 2, 3 etc is in 'offers' category. I want to add noindex to all products in this category. But leave indexing on all other categories ?

Website: SeenFirst


Newbie

Posts

Joined
Wed Feb 26, 2014 1:50 am


Post by vgosalia » Wed Jul 06, 2016 9:39 pm

Does this work with opencart 2.1.0.1.. Because this did not work for me..
Could you tell me what would be the change for 2.1.0.1 ?

Thansk!

Newbie

Posts

Joined
Wed Jul 06, 2016 9:37 pm

Post by saliverdim » Fri Jul 15, 2016 1:00 am

Dosn't Work for oc 2

can you Help Me ?

Active Member

Posts

Joined
Wed Oct 07, 2015 12:15 am

Post by jcusters » Fri Aug 19, 2016 5:30 pm

Hi,

Thanks mijomedia! This code still works for oc 2.x (with a small change). I have created a vqmod extension: http://www.opencart.com/index.php?route ... n_id=27650

Regards,
Jeroen

Newbie

Posts

Joined
Tue Jun 11, 2013 3:41 am

Post by Rainforest » Fri Dec 08, 2017 5:23 am

Does anyone know if this still works with OC 2.3.0.2? Or specifically with Journal 2 theme and using SEO Pro Pack?

Self Taught Opencart User & Developer Since 2010.


User avatar
Active Member

Posts

Joined
Fri Jan 28, 2011 3:50 am

Post by edgarcelso » Tue Mar 27, 2018 2:00 pm

i try on 2.3.0.2 with journal and it appers this

Notice: Undefined variable: robots in /home/xpto/public_html/catalog/view/theme/journal2/template/common/header.tpl on line 32

Code: Select all

<?php if ($robots) { ?>
<meta name="robots" content="<?php echo $robots; ?>" />
<?php } ?>
i don't know how to solve this :-[

Newbie

Posts

Joined
Mon Dec 09, 2013 6:08 am

Post by cosmicx » Thu Sep 06, 2018 3:46 pm

@edgarcelso

Read Here:
viewtopic.php?t=173034

Active Member

Posts

Joined
Mon Jan 09, 2012 6:27 pm

Post by sirenaplus » Tue Sep 18, 2018 3:09 pm

SEO is much more links, spam and directories listing. This was done until 2014, but now the Google algorithm has changed and those who have stayed in those techniques do only harm in the site they support. You can read on this SEO blog and learn more but as a company you should be interested in increasing your turnover first and establishing your brand first and foremost.

Newbie

Posts

Joined
Sat Sep 15, 2018 3:29 pm


Post by nightwing » Sat Feb 15, 2020 11:48 pm

Hey mijomedia, Could you please share a method for OC 3.0.3.2?

Thanks
mijomedia wrote:
Sat Jun 14, 2014 9:32 pm
Hello all,

In this tutorial i will show you how to put the meta tag <meta name="robots" content="noindex,follow"> on specific pages in OpenCart.

Q.A:

Why would i do this?

Out of the box is OpenCart pretty SEO-friendly, but you can always do this better with some tricks and fixes. This will put the meta tag on specific pages such as onsite search results. This is crucial for SEO purposes to avoid certain stuff like duplicate content and low quality pages. If you do not do this it can result bad SEO and in worst cases you can get penalized for bad content.

Why not use /disallow in robots.txt?

I have seen lost of posts in this forum on this case of problem, the thing is that the robots.txt do not "unindex" your pages and many of the search engines do ignore this file. And Google has announced that noindex,follow meta tag is the code you need.



The Tutorial:

To make this happen you need to code some in the core files. You can also make this with a VqMod file if you're not comfort with coding inside the core files.

Lets get going.


Find this file:

catalog/controller/common/header.php
Find line:

Code: Select all

$this->data['links'] = $this->document->getLinks();
After put this line:

Code: Select all

$this->data['robots'] = $this->document->getRobots();

system/library/document.php
Find line:

Code: Select all

private $description;
Above put this line:

Code: Select all

private $robots;
In same file you need to find this line:

Code: Select all

public function setDescription($description) {
Above put this line:

Code: Select all

public function setRobots($robots) {
		$this->robots = $robots;
	}
	public function getRobots() {
		return $this->robots;
	}

catalog/view/theme/YOUR_THEME/template/common/header.tpl
Find line:

Code: Select all

<?php if ($description) { ?>
<meta name="description" content="<?php echo $description; ?>" />
<?php } ?>
After put this line:

Code: Select all

<?php if ($robots) { ?>
<meta name="robots" content="<?php echo $robots; ?>" />
<?php } ?>
We have now done so the controller can put the meta tag on the pages we want them to have. What we need to do next is to define which pages to have this nice little bit of code.

This will be an example to put noindex,follow on search page.

Find this file:

catalog/controller/product/search.php
Find:

Code: Select all

$this->load->model('catalog/category');
After put this line:

Code: Select all

$this->document->setRobots('noindex,follow');
And there you have it. As i said before you can do this with VqMod. I don't know how to attach files on this forum, otherwise i would do it for you with some more pages to have this.

Hope this will help some people that want to tweak OpenCart even more in SEO purposes. Please check out the extension parts of this. Cause i am in work to make a real module for this.

/Mijo Media

Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing


Active Member

Posts

Joined
Tue Nov 05, 2019 11:08 pm


Post by straightlight » Sun Feb 16, 2020 12:09 am

Hey mijomedia, Could you please share a method for OC 3.0.3.2?
This is an old way of implementing such solution. Nowadays, we use the extension/extension to add the setRobots strings into the header.twig file without modifying core files.

Another optional way would be by implementing the TWIG modified engine from Opencart Github but does require core modifications.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Mon Feb 17, 2020 10:18 am

An alternative would be to use one-to-many of those free extensions: https://www.opencart.com/index.php?rout ... h=nofollow .

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by nightwing » Wed Feb 26, 2020 7:10 pm

Thanks straightlight...
straightlight wrote:
Mon Feb 17, 2020 10:18 am
An alternative would be to use one-to-many of those free extensions: https://www.opencart.com/index.php?rout ... h=nofollow .

Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing


Active Member

Posts

Joined
Tue Nov 05, 2019 11:08 pm

Who is online

Users browsing this forum: No registered users and 42 guests