Skip to content

Instantly share code, notes, and snippets.

@jasontipton
Created November 13, 2014 20:06
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jasontipton/9e35ae3f878282ba37ae to your computer and use it in GitHub Desktop.
Save jasontipton/9e35ae3f878282ba37ae to your computer and use it in GitHub Desktop.
Magento Local.xml NOINDEX/NOFOLLOW Catalog Search
<?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>
@jasontipton
Copy link
Author

To prevent search engines (Google, Bing, Yahoo, etc.) from needlessly indexing Magento catalog search results page(s) and advanced search results page(s) add the 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.

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

@dgitman
Copy link

dgitman commented Feb 14, 2018

You might want also want to remove Popular Search Terms from the SERPs. You can do this by adding

    <!-- Popular Search Terms-->
    <catalogsearch_term_popular>
      <reference name="head">
         <action method="setRobots"><value>NOINDEX,NOFOLLOW</value></action>
      </reference>
   </catalogsearch_term_popular>

@maynard321
Copy link

This is worth adding too, as Magento seems to generate a lot of links to catalogsearch/advanced/?....

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment