Hosting Tutorial & Guide

How to Hide a WordPress Page from Google Search

updated on Dec 21, 2016
How to Hide a WordPress Page from Google Search It is good to know that search engines crawl and index the pages on your website because better crawling and indexing mean much more search engine traffic. However, there are indeed some cases in which you may not want certain pages to be indexed, for example, the download page of your free resources, the newsletter confirmation page, or some thank you pages. Blocking the download page makes sure that people visit your website and read content before they can access the page instead of doing a single search quickly.

WordPress provides a feature to block search engines from indexing an entire site, which can be found in the Reading Settings in the admin area. But there is no built-feature allowing you to hide single posts or pages from search engines like Google.

Fortunately, there are several different methods with which you are able to stop Google from indexing specific posts/pages on your WordPress site without affecting the SEO. And in below, we will introduce them one by one, so you can select the method that suits you most.

Hide a WordPress Page or Post from Google by Editing Robots.txt

Robots.txt is a file that lets you control what content on your website should be indexed and what shouldn't. Normally this file is located in the root directory of your WordPress site, and if you don't have one, create a new text file, name it as Robots.txt and then upload it to the proper directory.

To block a WordPress post or page from Google, you only need to add the following lines to your Robots.txt file via an FTP client or cPanel.

User-agent: googlebot
Disallow: /your-wordpress-page/

In these lines, we use googlebot as the user agent, so a rule will be applied to Google. The certain rule here, then, is not to index the URL in the "Disallow" line. The URL can be any post or page on your WordPress site.

If you want to stop all other search engines besides Google from crawling and indexing the page, you can then use "*" as the user agent.

Using Robots.txt is an easy way to hide content from search engines, but this is not the best solution. Most search engines follow the instructions, but some bots and crawlers may ignore the file, especially those bad bots that harvest information or spread malware.

Hide a WordPress Page or Post by Using Robots Meta Tag

Robots meta tag is a good method that is recommended by Google for blocking URLs from search engines. As Google advises, you can use the following values to control the access to pages.

<meta name="robots" content="noindex">

These values mean all search engines are disallowed to display the page in the index. And if you simply want to block Google, then you can replace "robots" with "googlebot". Also, you are able to block multiple search engines at once by specifying the spiders in this way. Besides, "nofollow" can be added to the content to stop search engines from following links.

<meta name="googlebot,bingbot" content="noindex,nofollow">

After learning the robots meta tag, you now need to add it to your theme's header to make it work.

Add robots meta tag to your website

The robots meta tag introduced above will block all the pages on your website from search engines. So in the case that you only want to hide a certain post or page, you first have to find out the post/page ID. Then, open the header.php template of your theme, and place the following code within the head section.

<?php if ($post->ID == 123) { echo '<meta name="robots" content="noindex">'; } ?>

This code works for all of posts, pages, custom post types and attachments. "123" refers to the ID of the post or page that you want to hide. And if you have multiple posts/pages to block, simply add the IDs in the following way.

<?php if ($post->ID == 123 || $post->ID == 183) { echo '<meta name="robots" content="noindex">'; } ?>

After adding the code, save header.php.

Verify the robots meta tag

To check whether the robots meta tag has been placed and configured properly, you can visit the specific page and view the page source. If nothing is wrong, you will see the robots meta tag appearing in the page's head section.

View Page Source to Check Robots Meta Tag

Also, we'd suggest you check another page's source code to make sure that you are not blocking other pages mistakenly.

Hide a WordPress Page from Google with a Plugin

If you do not like dealing with code, you may want a plugin to simplify the entire process. Of course, there are some choices, among which Search Exclude is a good one. By installing this plugin, you can hide any WordPress post, page or attachment from search engines with a simple click on the "Exclude from Search Results" option on the editing screen.

Exclude from Search Results

For all the posts and pages that are hidden, you can get a list of them in Settings > Search Exclude. There you are able to make any of them visible to search engines by un-checking the title then saving the change.

Hidden Posts and Pages