XML sitemap best practices

A sitemap is only useful if search engines can trust it. A clean file lists the right pages, in the right form, with honest dates. Here is what to include, what to leave out, and the mistakes that show up most often in Search Console.

WorldmapPDFFree world maps in PDF, PNG and JPG
Checklist of URLs to include and to leave out of a sitemap
What belongs in a sitemap, and what does not

List only the pages you want in search results

Think of your sitemap as a list of recommendations. Every URL in it says "this page is worth indexing". If a third of the list turns out to be redirects, errors or duplicates, search engines learn that your recommendations are unreliable. A clean sitemap contains:

What to leave out

Keep the lastmod dates honest

Google has said that it uses lastmod when the dates are consistently accurate, and ignores changefreq and priority. Change the date only when the main content changes: a new paragraph, an updated price, a corrected fact. A new copyright year in the footer or a changed sidebar does not count. If you cannot produce reliable dates, leave the tag out rather than filling it with today's date.

Keep the file up to date

An old sitemap slowly fills up with deleted pages and misses the new ones. Generate it again whenever you publish a batch of pages, delete a section, or change your URL structure. On a site that changes every day, the sitemap should be produced automatically by the publishing system. On a site that changes a few times a month, regenerating it with a crawler and uploading it again is enough.

Technical checklist

Point to checkExpected value
EncodingUTF-8, with special characters escaped (&)
URLsAbsolute, same protocol and same host as the site
Size50,000 URLs and 50 MB maximum per file
HTTP response of the file200, readable without a login, not blocked by robots.txt
LocationAt the root, declared in robots.txt
CompressionOptional, gzip accepted (.xml.gz)

The most common errors in Search Console

Do not forget internal links

A sitemap helps search engines find pages, but it does not tell them a page is important. Internal links do that. A page that appears in the sitemap but receives no link from the rest of the site will often be crawled rarely and ranked poorly. Use the sitemap as a safety net, and make sure your menus and your content link to the pages that matter.

sitemapauto.com applies most of these rules for you: it follows your internal links, stays on your own domain, and keeps out every URL that answers with an error. You also get a report of the broken links it found along the way.

Frequently asked questions

Should every page of my site be in the sitemap?

No. Only the pages you want to see in search results: canonical, indexable and working pages.

Does the order of URLs in the sitemap matter?

No. Search engines do not give more weight to the first URLs of the file.

Should I include my images in the sitemap?

Not as separate URLs. Images can be described with the image sitemap extension, inside the entry of the page that displays them.

Can a bad sitemap hurt my rankings?

It will not cause a penalty, but a sitemap full of errors wastes crawl time and makes search engines trust your file less.

Sitemap guides

What is an XML sitemap?The format, the tags and a complete example you can copy. Submit a sitemap to Google and BingStep by step in Search Console and Bing Webmaster Tools. Declare your sitemap in robots.txtOne line that lets every search engine find your file. Sitemap index files for large sitesHow to split a big site into several sitemaps. Sitemap FAQShort answers to the questions webmasters ask most. How sitemapauto.com worksWhat happens between your URL and your sitemap.xml file.

Another free tool we built

Hunt down the broken links on your site

Bye404.org automatically scans a website and reports every dead link and 404 page it finds, broken images included. Broken links frustrate your visitors and waste crawl budget, so they are worth fixing before search engines run into them.

Scan my site for broken links on Bye404.org