Sub topic 1
Crawling vs. Indexing: What Each File Controls
Prerequisites
Assume you understand URLs, HTTP status codes, website directories, and basic XML. A crawler is a program that requests pages. A search index is the database used to answer searches.
Crawling vs. indexing: what each file controls
Crawling is the act of requesting and reading a URL. Indexing is storing information about that URL so it can appear in search results. Ranking is deciding its position for a particular query.
robots.txt mainly controls crawling. It tells cooperative crawlers which URLs they may request. An XML sitemap lists URLs that you want crawlers to discover. Neither file guarantees indexing or ranking.
Where robots.txt lives and how it is read
Place the file at the origin root:
https://www.example.com/robots.txt
A file at /docs/robots.txt does not control the whole site. Rules apply to the same scheme, host, and port. Crawlers usually fetch the file before requesting URLs, cache it, and apply rules for the relevant crawler identity.
A missing file generally means no crawling restriction. A server error can produce different behavior, so monitor availability.
Writing User-agent, Disallow, and Allow rules
User-agent starts a rule group. Disallow identifies paths a crawler should not request. Allow creates an exception.
User-agent: *
Disallow: /admin/
Disallow: /search
Disallow: /*?sessionid=
Disallow: /*.pdf$
Allow: /admin/help/The * user-agent value matches crawlers without a more specific group. An empty Disallow: permits crawling.
> callout note > robots.txt is not authentication. A blocked URL can still be requested by users or noncompliant programs.
Matching URLs with `*` and `$`
In supported robots syntax, * matches any sequence of characters. The final $ anchors a pattern to the end of the URL path. Thus, /*.pdf$ matches URLs ending in .pdf, while /*.pdf can also match URLs with additional characters afterward.
Which group and which rule applies
A crawler first selects the most specific matching User-agent group. If no specific group matches, it uses User-agent: *.
When several rules in that group match, the most specific, usually longest, match wins. If an Allow and Disallow match with equal specificity, Allow commonly wins. Test important patterns with the target search engine's tools.
Exercise
Should robots.txt block /private/report.html if the file contains Disallow: /private/?
Show answer
Yes. The path begins with /private/, so the rule matches.