Quick answer: To keep a page out of Google, add a noindex tag and let Google crawl the page so it can see the tag. A robots.txt block only stops crawling. A blocked page can still appear in results, usually without a description. For private content, use a password.
The difference, in short
- robots.txt Disallow: “Do not visit this URL.” Controls crawling. Does not remove a page from search.
- noindex: “You can visit, but do not show this page in results.” Controls indexing.
- Password: nobody, including search engines, can see the content.
How to add noindex
In the page HTML
<meta name="robots" content="noindex">
In WordPress, an SEO plugin adds this for you with a checkbox on each page.
For PDFs and other files
Files have no HTML, so send an HTTP header instead. On Apache or LiteSpeed, add this to .htaccess:
<FilesMatch "\.pdf$">
Header set X-Robots-Tag "noindex"
</FilesMatch>
For the whole site
WordPress has a checkbox in Settings → Reading: “Discourage search engines from indexing this site”. It adds noindex to every page. Use it for staging sites and sites that are not ready yet, and remember to turn it off at launch.
The most common mistake
People add noindex and block the page in robots.txt. Google then cannot crawl the page, so it never sees the noindex. The page can stay in results. Remove the robots.txt block until Google has dropped the page.
Also: Google does not support Noindex: lines inside robots.txt. They are ignored.
When robots.txt is the right tool
- Search result pages and filters that create endless URLs
- Admin areas, like
/wp-admin/ - Large files that waste crawling
- AI crawlers you do not want, see our AI crawlers guide
Need a page gone fast?
Add noindex (or delete the page so it returns 404 or 410). Then use the Removals tool in Google Search Console. It hides the page for about six months while Google processes your change.
Check it with our free tools: Robots.txt Generator and Tester · Meta Tag Checker · HTTP Headers Checker