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.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityTo 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>