---
title: "How to set NOINDEX NOFOLLOW for Specific Page in Magento 2"
url: "https://magecomp.com/blog/set-noindex-nofollow-for-specific-page-magento-2/"
date: "2021-09-24T15:37:32+00:00"
modified: "2025-02-19T05:06:09+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 355
reading_time: "2 min read"
summary: "Hello Magento Friends,"
description: "You can prevent web crawlers from crawling and indexing your webpage. Explore How to set NOINDEX NOFOLLOW for Specific Page in Magento 2."
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Magento 2: How to Add New Field in Admin User Create Form"
    url: "https://magecomp.com/blog/magento-2-add-new-field-in-admin-user-create-form/"
  - title: "Magento 2: How to Add Custom Field in Newsletter Subscription"
    url: "https://magecomp.com/blog/magento-2-add-custom-field-in-newsletter-subscription/"
  - title: "7 Best Magento 2 SMS Notification Extension Providers in 2026"
    url: "https://magecomp.com/blog/best-magento-2-sms-notification-extension-providers/"
---

# How to set NOINDEX NOFOLLOW for Specific Page in Magento 2

_Published: September 24, 2021_  
_Author: Dhiren Vasoya_  

![How to Set NOINDEX NOFOLLOW for Specific Page in Magento 2(1)](https://magecomp.com/blog/wp-content/uploads/2021/09/How-to-Set-NOINDEX-NOFOLLOW-for-Specific-Page-in-Magento-21-1024x512.webp)

**Hello Magento Friends,**

Today we will focus on How to set NOINDEX NOFOLLOW for Specific Page in Magento 2.
Magento allows managing instructions to index your website for web crawlers. You can control and prevent pages of your website to be indexed and crawled by search engines. For that, you can [**Configure Robots.txt in Magento 2**](https://magecomp.com/blog/configure-robots-txt-magento-2/).
[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Speed-Performance-Optimization-Services-CTA-1.webp)](https://magecomp.com/magento-performance-optimization.html)

NOINDEX stops web crawlers to crawl and index your webpage while NOFOLLOW stops web crawlers to follow links on the webpage. You can also Configure Robots.txt in Magento 2
Magento 2 gives the option to NOINDEX and NOFOLLOW for the whole site but whenever your site is live and sometimes you need to set NOINDEX and NOFOLLOW for a specific page then you need to follow the below steps
## Steps to set NOINDEX NOFOLLOW for Specific Page in Magento 2:
**Step 1:** First you need to create one **event.xml** file in the following path
**app\code\Vendor\Extension\etc\frontend\event.xml**

Now, add the below code
```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="layout_load_before">
        <observer name="add_robot_page" instance="VendorExtensionObserverNoindexfollow" />
    </event>
</config>
```

[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-6.webp)](https://magecomp.com/services/hyva-theme-development/)

**Step 2:** Now you need to create **Noindexfollow.php** in the following path
**app\code\Vendor\Extension\Observer\Noindexfollow.php**

And, add the code as follows
```
<?php
namespace VendorExtensionObserver;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;

class Noindexfollow implements ObserverInterface
{
    protected $request;

    protected $layoutFactory;

    public function __construct(
        MagentoFrameworkAppRequestHttp $request,
        MagentoFrameworkViewPageConfig $layoutFactory)
    {
            $this->request = $request;
            $this->layoutFactory = $layoutFactory;
    }
    public function execute(Observer $observer)
    {
        $fullActionName = $observer->getFullActionName();
        /* Here we give for category page, you can chages as per your need */
        if ($fullActionName == "catalog_category_view")
        {
                $this->layoutFactory->setRobots('NOINDEX,NOFOLLOW');
        }
    }
}
```

## Conclusion:
By doing so you can set NOINDEX NOFOLLOW for Specific Page in Magento 2 easily. If you face any problem implementing the above steps, drop a comment below. Spread the article with your friends and stay connected with us!
[![Hire Magento Programmer](https://magecomp.com/blog/wp-content/uploads/2025/02/Hire-Magento-Programmer-CTA-1.webp)](https://magecomp.com/services/hire-magento-programmer/)

**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/set-noindex-nofollow-for-specific-page-magento-2/](https://magecomp.com/blog/set-noindex-nofollow-for-specific-page-magento-2/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-09-24 12:26:30 UTC_  
