Page 1 of 1
[SOLVED] Put noindex,follow meta tag on specific pages SEO
Posted: Sat Jun 14, 2014 9:32 pm
by mijomedia
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:
Above put this line:
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
Re: [HOW TO] Put noindex,follow meta tag on specific pages S
Posted: Tue Jul 08, 2014 8:09 pm
by misscaprice
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
Re: [HOW TO] Put noindex,follow meta tag on specific pages S
Posted: Wed Jul 09, 2014 7:06 am
by Cue4cheap
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
Re: [HOW TO] Put noindex,follow meta tag on specific pages S
Posted: Mon Aug 11, 2014 11:49 pm
by bunny Chinh
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
Re: [HOW TO] Put noindex,follow meta tag on specific pages S
Posted: Mon Jan 11, 2016 2:10 pm
by mkp007
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
Re: [HOW TO] Put noindex,follow meta tag on specific pages S
Posted: Tue Mar 29, 2016 6:20 pm
by fewleh
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 ?
Re: [HOW TO] Put noindex,follow meta tag on specific pages S
Posted: Wed Jul 06, 2016 9:39 pm
by vgosalia
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!
Re: [HOW TO] Put noindex,follow meta tag on specific pages S
Posted: Fri Jul 15, 2016 1:00 am
by saliverdim
Dosn't Work for oc 2
can you Help Me ?
Re: [HOW TO] Put noindex,follow meta tag on specific pages S
Posted: Fri Aug 19, 2016 5:30 pm
by jcusters
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
Re: [HOW TO] Put noindex,follow meta tag on specific pages SEO
Posted: Fri Dec 08, 2017 5:23 am
by Rainforest
Does anyone know if this still works with OC 2.3.0.2? Or specifically with Journal 2 theme and using SEO Pro Pack?
Re: [HOW TO] Put noindex,follow meta tag on specific pages SEO
Posted: Tue Mar 27, 2018 2:00 pm
by edgarcelso
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
Re: [HOW TO] Put noindex,follow meta tag on specific pages SEO
Posted: Thu Sep 06, 2018 3:46 pm
by cosmicx
@edgarcelso
Read Here:
viewtopic.php?t=173034
Re: [HOW TO] Put noindex,follow meta tag on specific pages SEO
Posted: Tue Sep 18, 2018 3:09 pm
by sirenaplus
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.
Re: [HOW TO] Put noindex,follow meta tag on specific pages SEO
Posted: Sat Feb 15, 2020 11:48 pm
by nightwing
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:
Above put this line:
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
Re: [HOW TO] Put noindex,follow meta tag on specific pages SEO
Posted: Sun Feb 16, 2020 12:09 am
by straightlight
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.
Re: [HOW TO] Put noindex,follow meta tag on specific pages SEO
Posted: Mon Feb 17, 2020 10:18 am
by straightlight
An alternative would be to use one-to-many of those free extensions:
https://www.opencart.com/index.php?rout ... h=nofollow .
Re: [HOW TO] Put noindex,follow meta tag on specific pages SEO
Posted: Wed Feb 26, 2020 7:10 pm
by nightwing