Robots.txt vs Noindex: Which One Keeps a Page Out of Google?

Robots.txt vs Noindex: Which One Keeps a Page Out of Google?

What is the difference between robots.txt and noindex, and which one should you use to keep a page out of Google? Use noindex. Robots.txt controls whether Google may crawl a page, not whether the page can appear in search. This post shows the difference in plain words, the classic mistake that makes noindex stop working, and how to apply each one in WordPress. So, let’s start.

What is robots.txt, and what is noindex?

Robots.txt is a small text file at the root of your site, for example yourdomain.com/robots.txt. It tells crawlers which addresses they are allowed to visit. Google’s robots.txt introduction says its main purpose is to manage crawl traffic, and it states that robots.txt is not a mechanism for keeping a web page out of Google.

Noindex is an instruction on the page itself that says “you may read this page, but do not put it in your search results”. You add it as a robots meta tag in the page head, or as an X-Robots-Tag in the page’s HTTP response.

robots.txtnoindex
ControlsCrawling (visiting)Indexing (appearing in results)
Where it livesOne file at the site rootOn each page or in its response header
Keeps a page out of Google?No, not reliablyYes, when Google can read it

Why can a blocked page still show up in Google?

If other sites or pages link to an address you blocked in robots.txt, Google can still index the bare address and show it in results, usually without a description. Google’s help page for the indexing report repeats this: robots.txt does not guarantee that a URL stays out of the index, and to block indexing you should remove the rule and use noindex instead.

What is the classic mistake with noindex?

Putting both on the same page. Google’s guide to blocking indexing is clear: Google has to crawl the page to see the noindex rule. If robots.txt blocks the address, Google never sees the noindex, and the page can still appear. The fix is to unblock the page in robots.txt and let the noindex do its job. Google also does not support a noindex line inside robots.txt, so do not put one there.

When should you use which?

  • Use noindex for pages you do not want in search: thank-you pages, internal search results, thin tag pages, test pages.
  • Use robots.txt to save crawl effort on huge areas of little value, or to keep some media files out of results, but not as a privacy tool.
  • Use a password for anything private. Even Google says robots.txt does not protect sensitive content, because crawlers are not forced to obey it.
  • Use a canonical tag or a redirect when the issue is duplicate pages. We explain that in our guide to the [canonical tag in WordPress](/canonical-tag-wordpress-beginners/).

How do you add noindex in WordPress?

  • Rank Math or Yoast: open the post or page, find the Advanced tab in the SEO box, and set Robots Meta to noindex.
  • For whole groups, such as tag pages, use the plugin’s Titles and Meta settings for that content type.
  • Do not use the Settings, Reading option “Discourage search engines” as a normal tool. It affects the whole site, and is meant for sites in development.
  • For files like PDFs, use an X-Robots-Tag header, which your host or a small code snippet can send.

After you add it, open the page in URL Inspection and run a live test. It should say the page is excluded by noindex. Google may take time to drop the page after it recrawls.

What did we see on our own sites?

On therecipeworld.com, Search Console shows 687 pages under “Excluded by noindex”. We checked, and these are tag pages we set to noindex on purpose, while attachment pages redirect to their parent post. That is a good use of noindex.

On startupindiatoday.com we wanted about 27 weak old news posts out of Google without deleting them. The SEO plugin there cannot set noindex through its REST interface, so we added a tiny code file that sends a noindex header for those posts and removes them from the sitemap. To bring a post back, we remove its ID from the list. The header showed on the posts we tested, and the post sitemap now lists only seven posts. We have not yet seen Google drop them all, because that takes recrawling time.

What are the common mistakes?

  • Blocking a page in robots.txt and expecting it to disappear from Google.
  • Combining a robots.txt block with noindex on the same address.
  • Putting noindex on a page that is also in your sitemap. Keep the sitemap for pages you want indexed.
  • Blocking CSS or JavaScript files. Google warns that blocking resources can hurt its understanding of pages that need them.
  • Leaving “Discourage search engines” on after launch.
  • Noindexing useful pages by accident when a plugin option is changed. Check the pages you care about after every plugin or theme change.

Where are we less sure?

We do not know how long Google will take to remove a noindexed page on a small site, and we have only a few weeks of evidence. Our opinion: use noindex as the default tool for “keep this out of Google” and keep robots.txt short. A long robots.txt on a small blog usually causes more problems than it solves.

FAQ

Can robots.txt stop a page from being indexed?

Not reliably. Google can still index the address if other pages link to it. Use noindex, and let Google crawl the page.

Does noindex remove a page from my site?

No. Visitors can still open it. Only search results are affected.

How long does noindex take to work?

Google must recrawl the page to see the rule, so it can take days or weeks. You can request a recrawl with URL Inspection after you add it.

Quick checklist

  • Page you want hidden: noindex, not blocked in robots.txt.
  • Page you want found: no noindex, listed in the sitemap.
  • Private files: password protected.
  • Test with URL Inspection.
  • Review robots.txt twice a year.

If you want to see how Google reports these pages, read [what “Crawled – currently not indexed” means](/crawled-currently-not-indexed-fix/).

Sources

More guides on this topic

Scroll to Top