How to add NOINDEX NOFOLLOW in product page for magento 2
I need to change my meta tag to NOINDEX and NOFOLLOW for particular page (especially in product detail page) in magento 2. I have tried adding
<head>
<meta name="robots" content="NOINDEX,NOFOLLOW"/>
</head>
and also
<reference name="head">
<action method="setRobots"><value>NOINDEX,NOFOLLOW</value></action>
</reference>
In layout update xml but not changing from default how to fix the issue.
P.S.:I need to update via magento 2 backend.
magento2
add a comment |
I need to change my meta tag to NOINDEX and NOFOLLOW for particular page (especially in product detail page) in magento 2. I have tried adding
<head>
<meta name="robots" content="NOINDEX,NOFOLLOW"/>
</head>
and also
<reference name="head">
<action method="setRobots"><value>NOINDEX,NOFOLLOW</value></action>
</reference>
In layout update xml but not changing from default how to fix the issue.
P.S.:I need to update via magento 2 backend.
magento2
add a comment |
I need to change my meta tag to NOINDEX and NOFOLLOW for particular page (especially in product detail page) in magento 2. I have tried adding
<head>
<meta name="robots" content="NOINDEX,NOFOLLOW"/>
</head>
and also
<reference name="head">
<action method="setRobots"><value>NOINDEX,NOFOLLOW</value></action>
</reference>
In layout update xml but not changing from default how to fix the issue.
P.S.:I need to update via magento 2 backend.
magento2
I need to change my meta tag to NOINDEX and NOFOLLOW for particular page (especially in product detail page) in magento 2. I have tried adding
<head>
<meta name="robots" content="NOINDEX,NOFOLLOW"/>
</head>
and also
<reference name="head">
<action method="setRobots"><value>NOINDEX,NOFOLLOW</value></action>
</reference>
In layout update xml but not changing from default how to fix the issue.
P.S.:I need to update via magento 2 backend.
magento2
magento2
edited Apr 10 '18 at 7:56
Kirouthika K
asked Apr 10 '18 at 6:59
Kirouthika KKirouthika K
12
12
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
To resolve this issue, you can use event/Observer.
Create a small module.
Fire an Observer an observer on layout_load_before
event.
On this event make product details page is NOINDEX,NOFOLLOW
.
Event.xml:
events.xml is located at app/code/{Vendor}/{Modulename}/etc/frontend/
code should be like that
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="layout_load_before">
<observer name="add_robot" instance="{Vendor}{Modulename}ObserverNoindexfollowOnProduct" />
</event>
</config>
Observer class
NoindexfollowOnProduct.php is located at app/code/{Vendor}/{Modulename}/Observer
and
the code should be like that
<?php
namespace {Vendor}{Modulename}Observer;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
class NoindexfollowOnProduct implements ObserverInterface
{
protected $request;
protected $layoutFactory;
public function __construct(
MagentoFrameworkAppRequestHttp $request,
MagentoFrameworkViewPageConfig $layoutFactory
) {
$this->request = $request;
$this->layoutFactory = $layoutFactory;
}
public function execute(Observer $observer)
{
$fullActionName = $observer->getFullActionName();
/* Check Current page by full action */
if ($fullActionName == "catalog_product_view"){
$this->layoutFactory->setRobots('NOINDEX,NOFOLLOW');
}
}
}
Also, this module should have:
app/code/{Vendor}/{Modulename}/etc/module.xml
.app/code/{Vendor}/{Modulename}/composer.json
- .
app/code/{Vendor}/{Modulename}/registration.json
.
After adding the event you should flush the cache.
I need to add NOINDEX NOFOLLOW Only for selected product pages not all. Is that possible. Thanks
– Kirouthika K
Apr 10 '18 at 10:20
Yes, you can do for product wish. Insideif ($fullActionName == "catalog_product_view")
you can get product object by$observer->getLayout()->getBlock('product.info')-.>getProduct()
– Amit Bera♦
Apr 10 '18 at 10:35
add a comment |
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<meta name="robots" content="NOINDEX,NOFOLLOW"/>
</head>
</page>
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f221665%2fhow-to-add-noindex-nofollow-in-product-page-for-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
To resolve this issue, you can use event/Observer.
Create a small module.
Fire an Observer an observer on layout_load_before
event.
On this event make product details page is NOINDEX,NOFOLLOW
.
Event.xml:
events.xml is located at app/code/{Vendor}/{Modulename}/etc/frontend/
code should be like that
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="layout_load_before">
<observer name="add_robot" instance="{Vendor}{Modulename}ObserverNoindexfollowOnProduct" />
</event>
</config>
Observer class
NoindexfollowOnProduct.php is located at app/code/{Vendor}/{Modulename}/Observer
and
the code should be like that
<?php
namespace {Vendor}{Modulename}Observer;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
class NoindexfollowOnProduct implements ObserverInterface
{
protected $request;
protected $layoutFactory;
public function __construct(
MagentoFrameworkAppRequestHttp $request,
MagentoFrameworkViewPageConfig $layoutFactory
) {
$this->request = $request;
$this->layoutFactory = $layoutFactory;
}
public function execute(Observer $observer)
{
$fullActionName = $observer->getFullActionName();
/* Check Current page by full action */
if ($fullActionName == "catalog_product_view"){
$this->layoutFactory->setRobots('NOINDEX,NOFOLLOW');
}
}
}
Also, this module should have:
app/code/{Vendor}/{Modulename}/etc/module.xml
.app/code/{Vendor}/{Modulename}/composer.json
- .
app/code/{Vendor}/{Modulename}/registration.json
.
After adding the event you should flush the cache.
I need to add NOINDEX NOFOLLOW Only for selected product pages not all. Is that possible. Thanks
– Kirouthika K
Apr 10 '18 at 10:20
Yes, you can do for product wish. Insideif ($fullActionName == "catalog_product_view")
you can get product object by$observer->getLayout()->getBlock('product.info')-.>getProduct()
– Amit Bera♦
Apr 10 '18 at 10:35
add a comment |
To resolve this issue, you can use event/Observer.
Create a small module.
Fire an Observer an observer on layout_load_before
event.
On this event make product details page is NOINDEX,NOFOLLOW
.
Event.xml:
events.xml is located at app/code/{Vendor}/{Modulename}/etc/frontend/
code should be like that
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="layout_load_before">
<observer name="add_robot" instance="{Vendor}{Modulename}ObserverNoindexfollowOnProduct" />
</event>
</config>
Observer class
NoindexfollowOnProduct.php is located at app/code/{Vendor}/{Modulename}/Observer
and
the code should be like that
<?php
namespace {Vendor}{Modulename}Observer;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
class NoindexfollowOnProduct implements ObserverInterface
{
protected $request;
protected $layoutFactory;
public function __construct(
MagentoFrameworkAppRequestHttp $request,
MagentoFrameworkViewPageConfig $layoutFactory
) {
$this->request = $request;
$this->layoutFactory = $layoutFactory;
}
public function execute(Observer $observer)
{
$fullActionName = $observer->getFullActionName();
/* Check Current page by full action */
if ($fullActionName == "catalog_product_view"){
$this->layoutFactory->setRobots('NOINDEX,NOFOLLOW');
}
}
}
Also, this module should have:
app/code/{Vendor}/{Modulename}/etc/module.xml
.app/code/{Vendor}/{Modulename}/composer.json
- .
app/code/{Vendor}/{Modulename}/registration.json
.
After adding the event you should flush the cache.
I need to add NOINDEX NOFOLLOW Only for selected product pages not all. Is that possible. Thanks
– Kirouthika K
Apr 10 '18 at 10:20
Yes, you can do for product wish. Insideif ($fullActionName == "catalog_product_view")
you can get product object by$observer->getLayout()->getBlock('product.info')-.>getProduct()
– Amit Bera♦
Apr 10 '18 at 10:35
add a comment |
To resolve this issue, you can use event/Observer.
Create a small module.
Fire an Observer an observer on layout_load_before
event.
On this event make product details page is NOINDEX,NOFOLLOW
.
Event.xml:
events.xml is located at app/code/{Vendor}/{Modulename}/etc/frontend/
code should be like that
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="layout_load_before">
<observer name="add_robot" instance="{Vendor}{Modulename}ObserverNoindexfollowOnProduct" />
</event>
</config>
Observer class
NoindexfollowOnProduct.php is located at app/code/{Vendor}/{Modulename}/Observer
and
the code should be like that
<?php
namespace {Vendor}{Modulename}Observer;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
class NoindexfollowOnProduct implements ObserverInterface
{
protected $request;
protected $layoutFactory;
public function __construct(
MagentoFrameworkAppRequestHttp $request,
MagentoFrameworkViewPageConfig $layoutFactory
) {
$this->request = $request;
$this->layoutFactory = $layoutFactory;
}
public function execute(Observer $observer)
{
$fullActionName = $observer->getFullActionName();
/* Check Current page by full action */
if ($fullActionName == "catalog_product_view"){
$this->layoutFactory->setRobots('NOINDEX,NOFOLLOW');
}
}
}
Also, this module should have:
app/code/{Vendor}/{Modulename}/etc/module.xml
.app/code/{Vendor}/{Modulename}/composer.json
- .
app/code/{Vendor}/{Modulename}/registration.json
.
After adding the event you should flush the cache.
To resolve this issue, you can use event/Observer.
Create a small module.
Fire an Observer an observer on layout_load_before
event.
On this event make product details page is NOINDEX,NOFOLLOW
.
Event.xml:
events.xml is located at app/code/{Vendor}/{Modulename}/etc/frontend/
code should be like that
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="layout_load_before">
<observer name="add_robot" instance="{Vendor}{Modulename}ObserverNoindexfollowOnProduct" />
</event>
</config>
Observer class
NoindexfollowOnProduct.php is located at app/code/{Vendor}/{Modulename}/Observer
and
the code should be like that
<?php
namespace {Vendor}{Modulename}Observer;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
class NoindexfollowOnProduct implements ObserverInterface
{
protected $request;
protected $layoutFactory;
public function __construct(
MagentoFrameworkAppRequestHttp $request,
MagentoFrameworkViewPageConfig $layoutFactory
) {
$this->request = $request;
$this->layoutFactory = $layoutFactory;
}
public function execute(Observer $observer)
{
$fullActionName = $observer->getFullActionName();
/* Check Current page by full action */
if ($fullActionName == "catalog_product_view"){
$this->layoutFactory->setRobots('NOINDEX,NOFOLLOW');
}
}
}
Also, this module should have:
app/code/{Vendor}/{Modulename}/etc/module.xml
.app/code/{Vendor}/{Modulename}/composer.json
- .
app/code/{Vendor}/{Modulename}/registration.json
.
After adding the event you should flush the cache.
edited 7 mins ago
answered Apr 10 '18 at 7:32
Amit Bera♦Amit Bera
57.4k1474171
57.4k1474171
I need to add NOINDEX NOFOLLOW Only for selected product pages not all. Is that possible. Thanks
– Kirouthika K
Apr 10 '18 at 10:20
Yes, you can do for product wish. Insideif ($fullActionName == "catalog_product_view")
you can get product object by$observer->getLayout()->getBlock('product.info')-.>getProduct()
– Amit Bera♦
Apr 10 '18 at 10:35
add a comment |
I need to add NOINDEX NOFOLLOW Only for selected product pages not all. Is that possible. Thanks
– Kirouthika K
Apr 10 '18 at 10:20
Yes, you can do for product wish. Insideif ($fullActionName == "catalog_product_view")
you can get product object by$observer->getLayout()->getBlock('product.info')-.>getProduct()
– Amit Bera♦
Apr 10 '18 at 10:35
I need to add NOINDEX NOFOLLOW Only for selected product pages not all. Is that possible. Thanks
– Kirouthika K
Apr 10 '18 at 10:20
I need to add NOINDEX NOFOLLOW Only for selected product pages not all. Is that possible. Thanks
– Kirouthika K
Apr 10 '18 at 10:20
Yes, you can do for product wish. Inside
if ($fullActionName == "catalog_product_view")
you can get product object by $observer->getLayout()->getBlock('product.info')-.>getProduct()
– Amit Bera♦
Apr 10 '18 at 10:35
Yes, you can do for product wish. Inside
if ($fullActionName == "catalog_product_view")
you can get product object by $observer->getLayout()->getBlock('product.info')-.>getProduct()
– Amit Bera♦
Apr 10 '18 at 10:35
add a comment |
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<meta name="robots" content="NOINDEX,NOFOLLOW"/>
</head>
</page>
add a comment |
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<meta name="robots" content="NOINDEX,NOFOLLOW"/>
</head>
</page>
add a comment |
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<meta name="robots" content="NOINDEX,NOFOLLOW"/>
</head>
</page>
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<meta name="robots" content="NOINDEX,NOFOLLOW"/>
</head>
</page>
answered May 3 '18 at 6:07
Shawn AbramsonShawn Abramson
2,4371815
2,4371815
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f221665%2fhow-to-add-noindex-nofollow-in-product-page-for-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown