Sub topic 6
Blocking crawling is not the same as blocking indexing
This chapter assumes you can write basic robots.txt rules (User-agent, Disallow, Allow), that you know the difference between crawling and indexing, and that you can read HTTP headers and HTML <head> markup. The chapter covers how the two controls differ, why combining them often fails, and which one to pick for a given goal.
Two different controls
A search engine does two separate jobs with a URL:
- Crawling means requesting the URL and downloading its content.
- Indexing means deciding to store the URL in the search index so it can appear in results.
robots.txt controls the first job. A Disallow rule tells a compliant crawler not to request matching URLs. It says nothing about whether the URL may be listed in search results.
The noindex directive controls the second job. It tells a search engine not to show the page in results. To obey it, the crawler has to fetch the page and read the directive.
That dependency causes most of the confusion. The two controls are not interchangeable, and using both on the same URL can make the result worse.
What happens to a disallowed URL
Suppose /old-promo is disallowed in robots.txt and other sites link to it. The search engine learns the URL exists from those links. It cannot fetch the page, so it knows nothing about the content. It may still index the bare URL. The result often shows the URL with no description, or with text taken from the anchor text of links pointing to it.
So Disallow does not remove a page from search results. It only stops the crawler from reading the page. Google documents this behavior, and other engines act similarly.
How noindex works
You can express noindex in two places.
For HTML pages, use a meta tag in the <head>:
<meta name="robots" content="noindex">You can name a specific crawler instead of robots, for example googlebot. Other values can go in the same attribute, such as noindex, nofollow.
For any file type, including PDFs and images, send an X-Robots-Tag HTTP response header:
HTTP/1.1 200 OK
Content-Type: application/pdf
X-Robots-Tag: noindexThe header is the only option for files that have no HTML <head>. You can set it in your web server configuration or application code, often for a whole folder or file pattern at once.
Both forms require the crawler to receive a 200 response with the page or header. If the crawler is blocked, it never sees either one.
The common mistake: disallow plus noindex
A typical sequence goes like this. An editor wants a section out of search results. They add <meta name="robots" content="noindex"> to every page in it. Later someone adds Disallow: /section/ to "make sure" it stays hidden.
The Disallow now stops the crawler from fetching those pages. It never re-reads the noindex. Pages that were already indexed stay in the index, because the crawler cannot see the instruction to drop them. The second control cancels the first.
Do not put noindex in robots.txt
Some older guides show a Noindex: line inside robots.txt:
User-agent: *
Noindex: /private/Google never documented this and stopped honoring it on 1 September 2019. Treat it as unsupported. Use the meta tag or the X-Robots-Tag header.
Choosing between the two
Pick the control that matches your goal.
| Goal | Use | Why |
|---|---|---|
| Keep a page out of search results | `noindex` with crawling allowed | The crawler must read the directive. |
| Stop crawlers wasting requests on endless URL variations | `Disallow` | You save crawl effort, and the URLs have no content worth indexing anyway. |
| Keep a non-HTML file out of results | `X-Robots-Tag: noindex` header | PDFs and images have no `<head>`. |
| Keep content private | Authentication | Neither control is access control (see the next chapter). |
| Remove a page permanently | 404 or 410 status | The URL stops existing for the crawler. |
| Remove a page from results quickly and temporarily | Search engine removal tool | Removal tools such as Google's are temporary, so pair them with a permanent fix. |
Server load is the main reason to prefer Disallow. Faceted navigation, internal search, and session-ID URLs can produce huge numbers of near-duplicate URLs. Blocking them in robots.txt prevents the crawler from spending its budget there. You usually do not care whether a stray URL appears, because these URLs rarely have inbound links.
Removing an already indexed page the right way
If a URL is indexed and you want it gone, follow this order:
- Make sure robots.txt does not block the URL.
- Add
noindex(meta tag or header) and keep the page returning 200. - Wait for the crawler to revisit. You can request a recrawl in the search engine's webmaster tools to speed this up.
- Confirm the URL has dropped from the index.
- Only then, if you also want to save crawl effort, add a
Disallowrule. The page is already out, so nothing depends on the crawler reading it again.
If you want the page gone for good and have no need to keep it, delete it and return 410 or 404. If a replacement exists, use a 301 redirect to it.
Interaction with sitemaps
A URL should not be in your sitemap and also be marked noindex. The sitemap says "please index this" and the page says "do not". Search engines handle the conflict, but you will see it flagged as a warning in reports. Keep sitemaps limited to URLs you want indexed.
The same applies to disallowed URLs in a sitemap. Listing them signals that you want them discovered while also forbidding access.
Checking a URL with a script
This script combines both checks for one URL. It reads robots.txt, then fetches the page and looks for a noindex in the header or meta tag. It is a rough check: the regular expression assumes the name attribute appears before content in the tag, and it looks only at generic robots directives, not crawler-specific ones.
import re
import sys
from urllib.parse import urljoin
from urllib.request import Request, urlopen
from urllib.robotparser import RobotFileParser
AGENT = "*"
def check(url):
rp = RobotFileParser()
rp.set_url(urljoin(url, "/robots.txt"))
rp.read()
if not rp.can_fetch(AGENT, url):
return "Blocked by robots.txt: any noindex on the page cannot be seen."
request = Request(url, headers={"User-Agent": "noindex-check/1.0"})
with urlopen(request, timeout=10) as response:
header_values = response.headers.get_all("X-Robots-Tag") or []
body = response.read(200_000).decode("utf-8", errors="replace")
if any("noindex" in value.lower() for value in header_values):
return "Crawlable, and noindex is sent in the X-Robots-Tag header."
pattern = r"<meta[^>]+name=[\"']robots[\"'][^>]*content=[\"']([^\"']*)[\"']"
for content in re.findall(pattern, body, flags=re.IGNORECASE):
if "noindex" in content.lower():
return "Crawlable, and noindex is set in a meta tag."
return "Crawlable, with no noindex found: the page can be indexed."
if __name__ == "__main__":
print(check(sys.argv[1]))Run it with python check.py https://www.example.com/page. The first outcome, "Blocked by robots.txt", is the one to watch for on pages you are trying to deindex.
Edge cases
- Redirects. If a URL redirects, the crawler follows the redirect and reads the directives on the destination, not on the original. Put
noindexon the final page. - Caching. Search engines can take days or weeks to revisit a page, so deindexing is not instant even when everything is configured correctly.
- Changing your mind. If you remove
noindexlater, the page becomes eligible for indexing again, but it can take time to reappear. - Different agents. A group in robots.txt can allow one crawler and block another. A
noindexmeta tag addressed togooglebotdoes not affect other engines. - JavaScript-inserted tags. A
noindexadded by script only works if the crawler renders the page. Send it in the initial HTML or the header when you can.
Exercise
A page at /summer-sale was indexed by mistake. You add <meta name="robots" content="noindex"> to it, and also add "Disallow: /summer-sale" to robots.txt. Weeks later the URL still appears in search results. Why, and what should you change?
Show answer
The Disallow rule stops the crawler from fetching the page, so it never sees the noindex tag and has no reason to drop the URL. Remove the Disallow rule, keep the page returning 200 with the noindex tag, and wait for the crawler to revisit it (you can request a recrawl). After the URL leaves the index, you may add the Disallow rule again if you want to stop further crawling.
Exercise
You need a folder of PDF reports kept out of search results. PDFs have no HTML head. What do you use, and what must stay true about robots.txt?
Show answer
Send an X-Robots-Tag: noindex HTTP response header for those files, for example by configuring the web server for the folder or the .pdf pattern. robots.txt must not disallow those URLs, or the crawler cannot fetch the files and will not see the header. If the reports are confidential, also put them behind authentication.