Search code examples
magentoindexinggoogle-crawlers

Set NOINDEX, NOFOLLOW on particular products


My magento store has the following to allow google/search engines to crawl the entire site.

<meta name="robots" content="INDEX,FOLLOW" />

I am now in need for some particular products to have:

<meta name="robots" content="NOINDEX,NOFOLLOW" />

so that google doesn't crawl/index them. Is this possible? Products would be random (i.e not all from one category) so I need to be able to do this on a product by product basis if needed.

I know i could do it on a url basis like:

<?php
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
if ($currentUrl == 'xxxxxxx')
{
    <meta name="robots" content="NOINDEX,NOFOLLOW" />
}
else
{
    <meta name="robots" content="INDEX,FOLLOW" />
}
?>

but there could end up over time to be hundreds/thousands of these.


Solution

  • You can do this manually on a product-by-product basis by using the Custom Layout Update. In admin Catalog > Manage Products select your product, navigate to the design tab and int the Custom Layout Update field, insert the following:

     <reference name="head">
        <action method="setRobots"><value>NOINDEX,NOFOLLOW</value></action>
     </reference>
    

    If there are going to be hundreds you may need to look into doing this in your local.xml, maybe on a per-attribute basis..