Should you use robots.txt or noindex to hide a page?

By TechCompare · Updated · How we check

To keep a page out of Google, let Googlebot fetch it and add noindex. Blocking it in robots.txt can leave the URL in the results, since Googlebot never reads the noindex.

They do different jobs. A robots.txt rule asks crawlers not to fetch a URL. A noindex rule asks search engines not to show the page in results. The trap is using both on one page. If robots.txt blocks the page, the crawler never sees the noindex.

Topic
robots.txt vs noindex
Crawling vs indexing
Category
Search crawlers
Bingbot, Googlebot and indexing

How it works

Google's documentation says that if a page is blocked by robots.txt, the crawler will never see the noindex rule, and that the page can still appear in search results, for example because other pages link to it. For noindex to work, the page must not be blocked. Noindex goes in a meta tag in the page, or in an X-Robots-Tag HTTP header, which Google recommends for files that aren't HTML, like PDFs, video and images. Robots.txt fits a different goal: saving crawl effort on sections that don't need crawling, like endless filter pages. Neither one is security. RFC 9309 says the protocol isn't a substitute for valid content security measures, and listing a path in robots.txt makes it public. This tester reads robots.txt rules only. It doesn't look at meta tags or headers, so a page it shows as allowed can still carry a noindex.

Verdict

Keep Disallow off any page that carries noindex, or the noindex does nothing. If a URL is blocked and still shows up in results, remove the Disallow so the crawler can fetch the page and read the tag. For private content, use a login.

More Robots.txt scenarios

Block GPTBot
Two lines tell OpenAI's training crawler to stay out. Its search crawler and its page visits use other names.
View details
Google-Extended
A token for Gemini training, not a crawler. A rule for it never reaches Googlebot or Google Search.
View details
Block AI, keep search
Name each training crawler, leave Googlebot and Bingbot alone, and choose on purpose about the AI search bots.
View details

Frequently asked questions

Can a page blocked in robots.txt still appear in Google?
Yes. A block stops the fetch, not the listing. The crawler never opens the page, so it can't read anything on it, a noindex included.
Does noindex work inside robots.txt?
Not for Google. Its page says it supports the user-agent, allow, disallow and sitemap fields and ignores the rest. The tester marks a noindex line as ignored.
How do I keep a PDF out of search?
Send an X-Robots-Tag: noindex HTTP header with the file. Google recommends the header for non-HTML resources like PDFs, video and images, where there's no HTML to hold a meta tag. The file has to stay crawlable.