Blog / Technical SEO /

Robots.txt and noindex: when to use which

Here’s a mistake I’ve seen more than once. Someone wants a page out of Google. They add a noindex tag to be safe, and they block it in robots.txt to be extra safe. Weeks later, the page is still in Google.

That’s not bad luck. Doing both is exactly what keeps it there.

Robots.txt and noindex sound like they do the same job, and they don’t. Once the difference clicks, choosing between them is easy.

The one-line difference

  • robots.txt controls crawling: whether Google is allowed to visit a URL.
  • noindex controls indexing: whether Google is allowed to show a URL in search results.

Visiting and showing are different things. Google can show a URL it has never visited (if other pages link to it), and it can visit a URL without showing it.

robots.txt

A plain text file at yoursite.com/robots.txt that tells crawlers which parts of the site they shouldn’t request.

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php

Sitemap: https://yoursite.com/sitemap_index.xml

What it’s good for

  • keeping crawlers away from sections that waste their time: internal search results, endless filter combinations, admin areas
  • reducing load on your server from crawlers hitting thousands of useless URLs
  • pointing crawlers to your sitemap

What it doesn’t do

  • It doesn’t remove a page from Google. If a blocked URL has links pointing to it, Google can still index the URL, often showing it with a note that no information is available for the page.
  • It isn’t security. Anyone can read your robots.txt, and badly behaved bots ignore it. Never “hide” private pages this way. It’s like putting a sign on a door saying “nothing private in here”.

noindex

A tag in the page’s HTML (or an HTTP header) that tells search engines not to show the page in results:

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

On WordPress, your SEO plugin adds this for you when you tick “noindex” on a page or a whole content type.

What it’s good for

  • thank-you and confirmation pages
  • thin archive pages, like tags on most blogs
  • internal search results pages
  • duplicate or near-duplicate pages you need to keep for users
  • staging copies of a site

What it needs to work

Google has to crawl the page to see the noindex tag. If it can’t visit the page, it never sees the instruction.

Why using both backfires

This is the mistake from the start:

  1. You add noindex to a page.
  2. You also block it in robots.txt.
  3. Google is no longer allowed to visit the page.
  4. So Google never sees the noindex tag.
  5. If the page has links pointing to it, Google can keep it in the index.

To remove a page from Google, use noindex and let Google crawl it. Once it’s dropped out of the results, you can block it in robots.txt if you really need to save crawling, though for most small sites there’s no need.

Also worth knowing: putting noindex inside robots.txt doesn’t work. Google stopped supporting that in 2019.

Which to use: a quick guide

Situation Use
Page should exist for users, but not appear in search noindex
Page is in Google and you want it out noindex (and let it be crawled)
Thousands of useless URLs wasting crawling (filters, internal search) robots.txt (if they’re not already indexed), or noindex first
Admin or system areas robots.txt
Private content neither: use a password or login
Page is gone for good delete it (404/410) or redirect it
Staging site password protection, plus noindex as backup

A WordPress note

WordPress’s “Discourage search engines from indexing this site” setting (Settings → Reading) adds a noindex-style instruction to every page. It’s meant for sites that aren’t live yet, and forgetting to untick it is the first thing I check on any site (see the WordPress SEO checks I run first).

How to check what’s happening

  • Search Console URL inspection: paste a URL to see whether it’s indexed, whether crawling is allowed and whether a noindex was detected.
  • Search Console Pages report: look for “Blocked by robots.txt”, “Excluded by ‘noindex’ tag” and especially “Indexed, though blocked by robots.txt”, which is a sign of exactly the problem above.
  • Your robots.txt: just open it in a browser and read it. It should be short and make sense.

Have a look in your Search Console Pages report for “Indexed, though blocked by robots.txt”. If it’s there, you now know exactly what’s causing it.