Sub topic 12
Telling crawlers where your sitemaps are
A sitemap helps only if crawlers know it exists. This chapter covers the three ways to publish one: a Sitemap: line in robots.txt, a submission in a search engine's webmaster tool, and an automated ping or API where one is supported. It assumes you can read robots.txt directives and have a sitemap or sitemap index ready, as covered in earlier chapters.
The Sitemap directive in robots.txt
The simplest method works for every crawler that reads robots.txt. Add a line with the full, absolute URL of the sitemap or sitemap index:
User-agent: *
Disallow: /admin/
Sitemap: https://www.example.com/sitemap_index.xml
Sitemap: https://www.example.com/sitemap-news.xmlPoints to know:
- The directive is not tied to a
User-agentgroup. It applies to the whole file, wherever you place it. Putting it at the end, separated by a blank line, keeps the file readable. - The URL must be absolute, including the scheme and host.
Sitemap: /sitemap.xmlis invalid. - You can list several sitemaps by repeating the line.
- Point to the sitemap index if you have one. Crawlers follow it to each child sitemap, so you do not need to list the children.
Where the sitemap file may live
A sitemap can only describe URLs at or below its own location, unless cross-site rules allow otherwise. A file at https://www.example.com/blog/sitemap.xml may list URLs under /blog/ but not /shop/. Placing the file at the site root avoids this problem.
The scheme and host must also match. A sitemap on https://www.example.com should not list http:// URLs or URLs on example.com without www. If you run several hostnames, the Sitemap directive in robots.txt is one supported way to reference a sitemap hosted elsewhere, provided you control both sites.
Submitting in search engine tools
Webmaster tools give you feedback that robots.txt cannot. In Google Search Console, open Sitemaps, enter the sitemap path, and submit. Bing Webmaster Tools has an equivalent page. After a submission you can see:
- When the sitemap was last read.
- How many URLs were discovered.
- Parsing errors, such as invalid XML or URLs outside the allowed scope.
Submitting a sitemap index is enough. The tool reports on each child file separately.
Pings and other mechanisms
Google retired its sitemap ping endpoint in 2023, so requests to it no longer do anything. Bing and other engines that adopted IndexNow accept notifications of changed URLs through that protocol. IndexNow is a supplement for fast change reporting, not a replacement for a published sitemap.
Choosing a method
| Method | Reaches | Gives feedback | Effort |
|---|---|---|---|
| `Sitemap:` in robots.txt | Any crawler that reads robots.txt | No | One line |
| Webmaster tool submission | One search engine per tool | Yes | Manual, per engine |
| IndexNow | Engines that support it | Limited | Needs an automated hook |
Use robots.txt for coverage and a webmaster tool for diagnostics. Most sites do both.
Common errors
- Relative URL in the directive. The line is ignored. Use the full URL.
- Sitemap blocked by robots.txt. A rule such as
Disallow: /*.xml$stops crawlers from fetching the sitemap itself. Check that the sitemap path is allowed. - Wrong protocol or host. If the site redirects HTTP to HTTPS, list the final HTTPS URL, not one that redirects.
- Sitemap returns an error. A 404, a 5xx response, or an HTML login page makes the file unreadable. It must return 200 with XML content.
- Stale index. A sitemap index that lists files you deleted produces fetch errors in reports.
Exercise
Your robots.txt contains Sitemap: /sitemap.xml and Disallow: /*.xml$. Name two problems and give the corrected lines.
Show answer
The Sitemap URL is relative, and the Disallow rule blocks crawling of every .xml file, including the sitemap. Use Sitemap: https://www.example.com/sitemap.xml, and remove the Disallow rule or narrow it, for example Disallow: /feeds/*.xml$, so the sitemap path is not matched.
Exercise
You want search engines to find your sitemap index, and you also want to see parsing errors for it. Which two methods do you combine?
Show answer
Add a Sitemap: line with the index URL to robots.txt for discovery by any crawler, and submit the same URL in Search Console and Bing Webmaster Tools to get error reports.