Hiding a WordPress Post or Page From Google
Search engines like Google allow website owners to exclude content from search results. You can do this by using your site’s robots.txt file or using HTML meta tags.
We will show you how to do this in WordPress using two methods. You can choose the one that works best for you.
We will also show you how to password protect posts and pages in WordPress. If you don’t want to use the first two methods, then this approach will allow you to control the visibility of your posts and pages for all users.
Method 1: Hide a WordPress Page from Search Engines Using Yoast SEO
This method is easier and recommended for beginners.
First thing you need to do is install and activate the Yoast SEO plugin. For more details, see our step by step guide on how to install a WordPress plugin.
If you are new to Yoast SEO, then you may want to see our guide on how to install and set up Yoast SEO plugin.
Next, you need to edit the post or page that you want to hide from search engines. Scroll down to the Yoast SEO meta box below the post editor and click on the advanced settings button.
The advanced settings section allows you to add meta tag robots to your blog posts or pages. Using the robots meta tag, you can tell search engines not to index or follow a page.
First you need to select ‘noindex’ from the drop down menu next to ‘Meta robots index’ option. After that, click on ‘nofollow’ next to ‘Meta robots follow’ option.
You can now save/publish your post or page.
Yoast SEO will now add this line of code to your post or page:
Tables can't be imported directly. Please insert an image of your table which can be found here.1
This line simply tells search engines not to follow or index this page.
Method 2: Hide a WordPress Page from Search Engines Using robots.txt File
This method requires you to edit the robots.txt file. Adding incorrect instructions in this file can have adverse affect on your site’s SEO, which is why it is not recommended for beginner users.
The robots.txt file is a configuration file that you can add to your WordPress site’s root directory. It allows a website to provide instructions for search engine bots, hence the name robots.txt.
For more information, take a look at our guide on how to optimize your WordPress robots.txt for SEO.
You can edit robots.txt file by connecting to your website using an FTP client or ‘File Manager’ in your WordPress hosting cPanel.
You will need to add these lines to your robots.txt file.
The user-agent line allows you to target specific bots. We are using asterisk sign to include all search engines.
The next line defines the part of the URL that comes after your domain name.
Now let’s assume that you want to hide a blog post with a URL like this:
Here is how you will add this URL to your robots.txt file.
Don’t forget to save your changes and upload robots.txt file back to your server.
Disadvantages of Using robots.txt to Hide Content
First you need to keep in mind that robots.txt file is publicly accessible. Anyone can access it directly to see if there are any pages you are trying to hide.
While most search engines follow the instructions in robots.txt file, many other crawlers and bots may simply ignore it. These are the bots crawling the web to spread malware, target websites, or harvest information like email accounts, phone numbers, etc.
Method 3: Password Protect a Post or Page in WordPress
This method uses a different approach. Instead of asking search engines not to index a page, you can password protect it, so that it is only visible to users with the password.
WordPress comes with a built-in feature to password protect posts and pages. Simply edit the post or page that you want to protect.
Under the publish meta box, click on the ‘Edit’ link next to ‘Visibility’ option.
This will show the visibility options available in WordPress. You can keep a post/page public, make it private, or password protect it.
Private posts are only available to logged in users who have at least editor user role on your website.
Password protected posts can be seen by any visitor who has the password. Click on password protected option and then enter a strong password.
You can now publish or save your post/page.
Now visitors accessing the post or page on your website will be asked to enter the password to view the content.