7

As the title states: How can I add meta noindex to all catalog search result pages in Magento2?

I am hoping for an XML Layout solution.

1 Answer 1

11

To me you can simply create the following files in your module:

  • view/frontend/layout/catalogsearch_advanced_result.xml
  • view/frontend/layout/catalogsearch_result_index.xml

In case of a theme, the file locations will be different, under your theme folder:

  • Magento_CatalogSearch/layout/catalogsearch_advanced_result.xml
  • Magento_CatalogSearch/layout/catalogsearch_result_index.xml

And add the following content to those files (same content for both):

<?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> 
2
  • Hi, this works nice for catalogsearch, what about to add noindex to /customer urls? Commented Oct 27, 2020 at 5:30
  • magento.stackexchange.com/questions/302721/… Commented Dec 13, 2023 at 14:30

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.