PHP Magento Tips

Add NOINDEX/NOFOLLOW Robots meta tag to Catalog Search Results in magento

Rate this posting:
{[['']]}

To prevent search engines (Google, Bing, Yahoo, etc.) from needlessly indexing Magento catalog search results page(s) and advanced search results page(s) add below code to app/design/frontend/YOUR_PACKAGE/YOUR_THEME/layout/local.xml.

If this file does not yet exist in your custom theme you can create it and Magento will automatically include it.

If this file already exists in your custom theme then copy everything except the first line XML declaration and elements into your copy of local.xml.

<?xml version="1.0"?>
<layout version="0.1.0">

    <!-- Search Results page -->
    <catalogsearch_result_index>
      <reference name="head">
         <action method="setRobots"><value>NOINDEX,NOFOLLOW</value></action>
      </reference>
   </catalogsearch_result_index>

    <!-- Advanced Search page -->
    <catalogsearch_advanced_result>
      <reference name="head">
         <action method="setRobots"><value>NOINDEX,NOFOLLOW</value></action>
      </reference>
   </catalogsearch_advanced_result>
   
</layout> 

You can then test the results on your Magento website with the following URLs:

Search Results page:
http://yourwebsite.com/catalogsearch/result/?q=test

Advanced Search Results page:
http://yourwebsite.com/catalogsearch/advanced/

Once the page has loaded open up the developer tools (shortcut - F12) or view the generated source code (shortcut - Control + U) and look for 'robots'. The robots setting will display:

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

*You may need to flush Magento caches (Admin->System->Cache Management) to see the updated results
Tag : Magento
2 Comments On "Add NOINDEX/NOFOLLOW Robots meta tag to Catalog Search Results in magento"

Back To Top