Google has employed its web crawlers to crawl and index the web pages in order to make it visible in search. However thankful we are for that, we don’t want Google’s bots to index certain pages of our Magento 2 store like admin URL, staging sites, or admin login page! The reasons may be either privacy, security or the pages are yet under development, but for implementing particular features, you had to connect it to the web!
Also, in the efforts to hide such pages from search engines like Google, we do not want it to affect the store’s overall SEO too! Fortunately, search engines allow store owners to restrict which pages not to index!
For instance, to prevent Google from indexing Magento 2 admin URL, follow the simple method given below:
Method to Prevent Google From Indexing Magento 2 Admin URL:
Add the below code in app/design/adminhtml/default/default/template/page/head.php file
<meta name=“robots” content=“noindex” />
To hide the Magento 2 admin login page from Google, add the similar code in app/design/adminhtml/default/default/template/login.phtml
Easy and quick!
There’s another method to hide Magento 2 pages from Google using the robots.txt file. Create well-defined robots.txt and the second method at How to Configure Robots.txt and Meta Robots for Magento 2
Thanks!