What Is sitemap.xml and How Do You Submit It to Google?
sitemap.xml is a file that directly tells search engines the list of pages on a site. It's especially useful for getting new pages, or ones only reachable through deep links, discovered faster.
Summary
sitemap.xml is a file that directly tells search engines the list of pages on a site. It's especially useful for getting new pages, or ones only reachable through deep links, discovered faster.
Step by step
- Generate the sitemap with a tool rather than writing it by hand, which isn't practical beyond a small site.
- Only include pages you actually want indexed. Don't list pages that redirect or carry a noindex tag.
- Submit the file to Google Search Console. Skip this and you're just waiting for a bot to stumble onto it.
- Keep the sitemap current as the site grows. Old or deleted pages still listed just waste crawl time.
Why it matters
Search engines mostly find pages by following links. On a brand-new site with no inbound links, or for a product page buried five clicks deep, that process is slow. A sitemap hands crawlers a direct list that says these pages exist and you care about them. Being in the sitemap doesn't guarantee indexing. It does speed up discovery, and it makes the Search Console reports far more useful for working out why a particular page isn't indexed.
What goes inside the file
Each page gets a url entry containing its full address in a loc tag. Optionally, a lastmod tag records when the page last changed in a meaningful way. Google has said it ignores the priority and changefreq fields, so your time is better spent keeping lastmod accurate. A single sitemap file can hold up to 50,000 URLs and be up to 50 MB uncompressed. Bigger sites split their URLs across several files and list them in a sitemap index file.
Common mistakes
- Resetting lastmod to today on every build. If every page looks freshly updated when nothing changed, Google may stop trusting the field.
- Mixing http and https, or www and non-www addresses. URLs in the sitemap should match the site's canonical version exactly.
- Putting the sitemap in a folder blocked by robots.txt, or listing blocked pages inside it.
- On a multilingual site, only listing pages in one language. Every language version belongs in there.
- Ignoring a 'couldn't fetch' or parsing warning in Search Console. One invalid XML character can stop the whole file from being processed.
A realistic scenario
A statically generated tools site rebuilds its sitemap every time a new tool goes live. After a while, the 'Submitted but not indexed' count in Search Console starts climbing. Digging in, the owner finds deleted pages still listed and lastmod changing on every build. The build script gets fixed to include only live pages that don't redirect, and to set lastmod from the date the page's content file actually changed.
Pair it with robots.txt
Besides submitting the sitemap in Search Console, add a Sitemap line with its full URL at the end of robots.txt. That way other search engines can find it too. Every so often, check that the two files don't contradict each other, meaning nothing listed in the sitemap is blocked by robots.txt.