Sub topic 1
Crawling vs. indexing: what each file controls
Prerequisites
This chapter assumes you can do the following:
- Read a URL and name its parts: scheme, host, path, and query string.
- Recognize common HTTP status codes such as 200, 301, 404, and 503.
- Read simple XML, meaning nested tags and attributes.
- Run a short Python script (helpful, not required).
You don't need prior SEO experience. This chapter sets up the vocabulary and mental model that the rest of the tutorial uses.
Three stages: crawling, indexing, ranking
A search engine handles a page in three separate stages. Each stage can succeed or fail independently of the others.
- Crawling is the act of requesting a URL over HTTP and downloading the response. A program called a crawler (also called a bot or spider, for example Googlebot or Bingbot) does this.
- Indexing is the act of analyzing the downloaded content and storing it in the search engine's database, the index. Only indexed pages can appear in results.
- Ranking is the act of choosing and ordering indexed pages for a particular query. It depends on relevance, quality, location, and many other signals.
Crawling does not guarantee indexing. A crawler may fetch a page and then decide not to index it because it is a duplicate, has thin content, returns an error, or carries a noindex instruction. Indexing does not guarantee a good ranking either.
The two files in this tutorial work at the first two stages only:
robots.txttells crawlers which URLs they may request. It acts at the crawling stage.- An XML sitemap tells crawlers which URLs you want them to discover. It acts at the discovery step that feeds crawling.
Neither file ranks anything. Neither file is a command that a search engine must obey in every case.
What robots.txt controls
robots.txt is a plain text file at the root of a host. It holds rules that say which paths a crawler should not request. A well-behaved crawler downloads this file first, then follows the rules for its own name.
Here is a minimal file:
User-agent: *
Disallow: /private/This tells every crawler not to request URLs whose path begins with /private/. Later chapters cover the syntax in detail. For now, the key point is the scope of the rule: it limits fetching. It says nothing directly about what appears in search results.
Practical reasons to restrict crawling include:
- Saving server load. Crawlers can hammer expensive pages such as internal search results or filtered listings.
- Saving crawl budget. Crawl budget is the number of URLs a crawler is willing to fetch from your site in a given period. On large sites, wasting it on endless URL variations delays the discovery of useful pages.
- Avoiding junk URLs. Session IDs, calendar pages, and cart URLs produce near-infinite sets of low-value addresses.
Robots.txt is also a poor tool for some jobs. It cannot remove a page from the index, and it cannot protect confidential content. Those limits get their own chapters.
What a sitemap controls
An XML sitemap is a file that lists URLs you consider important, optionally with metadata such as the last modification date. This is a small valid example:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.example.com/</loc>
<lastmod>2026-11-01</lastmod>
</url>
</urlset>A sitemap helps discovery. Crawlers normally find pages by following links. A sitemap gives them a second route, which matters most in these situations:
- The site is new and has few inbound links.
- The site is large, and some pages sit many clicks away from the home page.
- Pages are poorly linked, for example orphan pages that no other page links to.
- Content changes often and you want crawlers to notice updates.
A sitemap is a hint, not a command. Listing a URL does not force a crawler to fetch it, and it does not force indexing. A crawler may skip listed URLs that look low quality, duplicate, or blocked. Leaving a URL out of a sitemap does not keep it out of the index either, because the crawler can still find the URL through links.
Side-by-side comparison
| Question | robots.txt | XML sitemap |
|---|---|---|
| Main purpose | Limit which URLs crawlers request | Suggest which URLs crawlers should discover |
| Stage affected | Crawling | Discovery, which feeds crawling |
| Format | Plain text, line-based rules | XML |
| Location | Root of the host, `/robots.txt` | Any path you choose, announced to crawlers |
| Binding on crawlers? | Followed by reputable crawlers, but voluntary | Treated as a hint only |
| Can remove a page from search results? | No | No |
| Can hide a page from people? | No | No |
Why blocking a crawl does not block indexing
This is the most common misunderstanding about robots.txt, so it is worth stating early.
If you disallow a URL, the crawler does not fetch it. But the crawler can still learn the URL exists, for example from a link on another site. The search engine may then index the bare URL, using the anchor text of the links that point to it. The result appears in searches with no description, because the content was never read.
Compare two goals:
- "Don't let crawlers request this." Use
robots.txt. - "Don't show this page in search results." Use a
noindexinstruction, either a robots meta tag or anX-Robots-TagHTTP header.
The two goals can conflict. A noindex tag lives in the page itself. If robots.txt blocks the page, the crawler never fetches it and never sees the tag. The page can then stay in the index. To remove a page, leave it crawlable until the noindex has been processed. A later chapter covers this in depth.
A conflict worth noticing: sitemap and robots.txt disagree
Because the files work independently, you can make them contradict each other. If a sitemap lists https://www.example.com/private/report.html and robots.txt disallows /private/, you are saying "please discover this" and "do not fetch this" at once. Crawlers generally respect the Disallow, and search consoles report such URLs as "blocked by robots.txt" or "submitted URL blocked." The fix is to make the files agree. A sitemap should list only URLs that you want crawled and indexed, and that return a 200 status.
Checking the crawl rule yourself
You can see the crawling side with Python's built-in parser. This script needs no network access, because it parses rules from a list:
from urllib.robotparser import RobotFileParser
rules = [
"User-agent: *",
"Disallow: /private/",
]
rp = RobotFileParser()
rp.parse(rules)
print(rp.can_fetch("*", "https://www.example.com/private/report.html"))
print(rp.can_fetch("*", "https://www.example.com/blog/"))The first call prints False and the second prints True. The answer concerns fetching only. Nothing in this output tells you whether either URL is indexed. That information comes from the search engine, for example through the URL inspection report in a search console.
Edge cases to keep in mind
- Scope is per host. A
robots.txtfile applies only to the exact scheme, host, and port it is served from.https://www.example.com/robots.txtdoes not coverhttps://blog.example.com/orhttp://www.example.com/. - Missing file is not an error. If
/robots.txtreturns 404, crawlers generally treat the whole site as crawlable. A server error (5xx) is treated more cautiously, and some crawlers pause crawling the site until the file loads again. - Caching. Crawlers cache
robots.txt, often for up to a day. A change you make may not take effect immediately. - Crawlers differ. Major search engines follow the rules, but some bots ignore them. Individual crawlers also differ in details such as support for non-standard directives.
- Sitemap URLs can cross hosts only with care. A sitemap generally should list URLs from the host where it lives. Cross-host submission has extra verification rules.
Summary of what each file controls
Use robots.txt when you want to steer crawler traffic away from URL areas. Use a sitemap when you want to help crawlers find the pages that matter. Use noindex when you want a page out of search results. Use authentication when content must be private. The remaining chapters build on these four distinctions.
Exercise
A page at /old-promo/ must disappear from search results. A teammate adds "Disallow: /old-promo/" to robots.txt and a "noindex" meta tag on the page. Weeks later the URL still appears in results with no description. What went wrong, and what is the fix?
Show answer
The Disallow rule stops the crawler from fetching the page, so it never sees the noindex tag. The URL can stay in the index because other pages link to it. The fix is to remove the Disallow rule so the page is crawlable, keep the noindex tag, and wait until the crawler has re-fetched the page and dropped it. After it is removed, you can decide whether to block crawling.
Exercise
Your sitemap lists 200 product URLs, and robots.txt contains "Disallow: /products/". Which file wins, and what should you change?
Show answer
Crawlers will respect the Disallow rule, so the products will not be fetched even though the sitemap lists them. The files contradict each other. If you want the products crawled, remove or narrow the Disallow rule. If you don't, remove the URLs from the sitemap.