What is an XML sitemap?
An XML sitemap is a machine-readable list of a site's pages, written for search engines. Google describes a sitemap as a file where you provide information about the pages, videos and other files on your site, which search engines read to crawl the site more efficiently.
It is a discovery aid, not a command. Google states that a sitemap does not guarantee every listed item will be crawled and indexed, and that leaving a URL out does not stop it being indexed if Google finds it through links.
Do you need a sitemap?
Google's guidance depends on the site.
| You probably need one if | You might not if |
|---|---|
| The site is large | The site is small, about 500 pages or fewer |
| The site is new, with few external links | Every important page is reachable by links from the home page |
| It has a lot of video, images or news content | It has little media or news content you need in search |
Even so, Google adds that in most cases a site will benefit from having one, and most CMS platforms generate it automatically.
What does a sitemap look like?
A sitemap is a list of url entries inside a urlset element. Each entry has a loc value, the full address of the page, and can have a lastmod value, the date the page last changed in a meaningful way. Large sites use a sitemap index: a file that lists several sitemaps.
Google's limits are 50,000 URLs or 50 MB uncompressed per sitemap file. Beyond that, split the list into several files.
How do you create and submit a sitemap?
- Generate it from your CMS, framework or a sitemap plugin, so it updates when pages change.
- Include only canonical, indexable URLs that return a normal page. Leave out redirects, error pages, duplicates and anything marked noindex.
- Use absolute URLs.
- Keep lastmod honest. Change it when the content changes.
- Submit it in Google Search Console and reference it with a Sitemap line in robots.txt.
- Check the report afterwards for URLs submitted but not indexed.
XML sitemap vs HTML sitemap
An XML sitemap is for crawlers. An HTML sitemap is an ordinary page of links for people, and acts as internal linking. The first helps pages get found. Neither replaces a site structure where important pages are a few clicks from the home page.
Sitemap vs robots.txt
A sitemap says "these are the pages I want crawled". Robots.txt says "do not fetch these". They should never contradict each other: a URL listed in the sitemap must not be blocked.