I need to insert <meta name="robots" content="NOINDEX,NOFOLLOW"/>
in a specific category page of our Magento site. Could you please share an example of how to do it? I don't want to use any module for this. I want the page to appear in the site menu and be available to users. I just don’t want it crawled. Here is page I'm talking about.
-
1You should create "Custom Layout Update" xml file. Bcz magento2.4 does not provide Layout update xml in admin category design.– S.PMay 11 at 12:44
-
create "catalog_category_view_selectable_<Category ID>_<Layout Update Name>.xml" in theme and set there.– S.PMay 11 at 12:46
-
S.P, what should I put in here <Layout Update Name>? and which directory should this file go in?– CodeForGoodMay 11 at 13:38
-
you can set any name there. Ex catalog_category_view_selectable_182_ROBOTCHANGE.– S.PMay 11 at 13:51
-
here 182 is category id. and ROBOTCHANGE Would be display in category DESIGN -> CUSTOM LAYOUT UPDAT Field.– S.PMay 11 at 13:53
1 Answer
you can Change Category Layout for Specific Category.
Suppose your categor id is 182. and you wish to your category custom layout name is CHANGEROBOT.
catalog_category_view_selectable_182_CHANGEROBOT.xml
create category custom layout file in theme or module.
app/code/{{module}}/{{modulename}}/view/frontend/layout/catalog_category_view_selectable_{{categoryid}}_{{customlayoutname}}.xml
or
app/design/frontend/{{theme}}/{{themename}}/Magento_Catalog/layout/catalog_category_view_selectable_{{categoryid}}_{{customlayoutname}}.xml
set your metadata there.
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<meta name="robots" content="NOINDEX,NOFOLLOW"/>
</head>
your customlayout would be load on cateogy custom layout update field.
CATALOG > CATEGORY > DESIGN > CUSTOM LAYOUT UPDATE (set new layout).
clean cache and check in your category page.
you can get better idea from reference : https://www.magevision.com/blog/post/change-category-layout-for-specific-category-magento-2