4

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.

5

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.