How the two files differ
Sitemap.xml is a list of URLs you want to show a search engine, with update dates. It helps new pages get found faster, especially on large sites and projects with few inbound links. The file sits in the site root and is submitted to Search Console and Yandex Webmaster.
Robots.txt is an instruction for robots about where not to go. It blocks service sections: the cart, the account area, internal search results, and duplicates with parameters. It is important to understand that blocking in robots.txt does not remove a page from search results if external links point to it. To exclude a page completely, use the noindex meta tag.
What should go into the sitemap
- Only pages that return a 200 code and have no redirects
- Only pages you want to see in search
- Canonical URLs without extra parameters and tags
- An accurate last-modified date, not today's date on every page
- No more than 50,000 URLs per file; otherwise split it into several
- Different language versions, if any, linked to each other
What to block in robots.txt
Block what is not needed in search and only wastes crawl budget: the cart and checkout, the account area, filter pages with endless combinations, print pages, site search results, and test copies. Do not block style and script files: the robot needs to see the page the way a user sees it.
The file should state the sitemap address with a Sitemap line. During development, a rule blocking the whole site is often set so search engines do not see unfinished pages. The costliest mistake is forgetting to remove it at launch: the site goes unindexed for weeks and nobody understands why.
Checking after launch
Open the file URLs
your-site/robots.txt and your-site/sitemap.xml should open and contain current data.
Make sure nothing is blocked
On the live site, robots.txt must not contain a "Disallow: /" line for all robots.
Submit the sitemap in webmaster tools
In Google Search Console and Yandex Webmaster, add the sitemap URL and check the processing status.
Review the indexing reports
Pages excluded "by noindex tag" or "blocked by robots.txt" should not include important ones.