What robots.txt does
robots.txt is a plain text file at the root of your domain that tells search engine crawlers which paths they may and may not request. It's the first file Googlebot looks for on a site, and a few lines in it can steer how your entire crawl budget is spent.
The key distinction — the one that trips up most people — is that robots.txt controls crawling, not indexing. Disallowing a URL stops bots from fetching it, but if other pages link to that URL it can still appear in search results, just without a description. To keep a page out of the index entirely, allow crawling and use a noindex meta tag instead.