How to Create a sitemap.xml: Limits, lastmod and Sitemap Index Files

Last updated: · 8 min read

A sitemap (sitemap.xml) is an XML file that lists the URLs on your site that you would like search engines to crawl. The format is defined by the Sitemap protocol published at sitemaps.org, and Google and other search engines read the same format. The file looks simple, yet small slips can cause the whole file or individual URLs to be ignored: relative URLs, an unescaped ampersand, URLs from different hosts mixed together, or lastmod dates that do not reflect reality. This guide explains the structure of the file, the limits set by the protocol, sitemap index files for sites with more than 50,000 URLs, and how to tell search engines where the file is. A sitemap is a hint; it does not guarantee that a URL will be crawled or indexed. The lines in the worked example are real output from the XML Sitemap Generator.

Formula

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://www.example.com/page</loc>       required; absolute URL, under 2,048 characters
    <lastmod>2026-01-15</lastmod>                 optional; W3C Datetime format
    <changefreq>weekly</changefreq>               optional; a hint only
    <priority>0.8</priority>                      optional; 0.0 to 1.0, default 0.5
  </url>
</urlset>

Per file     : at most 50,000 URLs and 50 MB (52,428,800 bytes, uncompressed)
XML escaping : &  →  &amp;    '  →  &apos;    "  →  &quot;    >  →  &gt;    <  →  &lt;

For larger sites, a sitemap index (at most 50,000 sitemaps):
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap><loc>https://www.example.com/sitemap-1.xml</loc></sitemap>
  <sitemap><loc>https://www.example.com/sitemap-2.xml</loc></sitemap>
</sitemapindex>

The root of the file is the urlset element; each URL sits in its own url element and is given in a loc tag. The protocol requires the file to be UTF-8 encoded and every URL to be written in full, with protocol and host, and all of them must use the same protocol and host as the sitemap itself. Every tag except loc is optional. lastmod gives the date the page last changed in W3C Datetime format: either a date alone (YYYY-MM-DD) or a full timestamp with a time zone. The tool parses and rewrites each URL: it percent-encodes non-ASCII characters, escapes the five characters that have a special meaning in XML, drops any fragment starting with #, removes duplicates and stops if it meets a URL that belongs to a different site.

What the inputs mean

URLs
One absolute URL per line, starting with http:// or https://. Adding " | 2026-01-15" at the end of a line sets the lastmod value for that URL. All URLs must share the same protocol and host; up to 50,000 URLs are processed.
Default last-modified date
Optional. Applied to URLs that have no date of their own. It must be a real calendar date in the form YYYY-MM-DD or 2026-01-15T09:30:00+03:00; if you give a time, give the time zone as well.
Change frequency (changefreq)
Omit by default. If selected, the same value is added to every URL: always, hourly, daily, weekly, monthly, yearly or never.
Priority
Omit by default. If selected, the same value (1.0, 0.8, 0.5 or 0.3) is added to every URL. The value is only a relative hint among the pages of one site.

Worked example: A three-URL sitemap, one URL with its own date

  1. Input: three lines. The first is https://www.example.com/, the second https://www.example.com/about | 2026-01-15 and the third https://www.example.com/blog/first-post. Default last-modified date = 2026-11-20; change frequency and priority = Omit.
  2. The first two lines of the output are the XML declaration and the root element: <?xml version="1.0" encoding="UTF-8"?> and <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  3. The first URL is written as <loc>https://www.example.com/</loc> and, having no date of its own, receives the default: <lastmod>2026-11-20</lastmod>
  4. The second line carries a date, which is used instead of the default: <loc>https://www.example.com/about</loc> and <lastmod>2026-01-15</lastmod>
  5. The third URL, <loc>https://www.example.com/blog/first-post</loc>, again gets the default date, and the file closes with </urlset>. Because changefreq and priority were not selected, those tags do not appear.
  6. The notes under the output read: 3 URLs written. Google ignores changefreq and priority; it uses lastmod only when the value is consistently accurate. Upload the file to the root of your site and submit its URL with a Sitemap line in robots.txt or in Search Console.
  7. Special characters: the URL https://www.example.com/ürünler?renk=mavi&beden=m is written as <loc>https://www.example.com/%C3%BCr%C3%BCnler?renk=mavi&amp;beden=m</loc>. The letter ü is percent-encoded from its UTF-8 bytes (%C3%BC) and the ampersand becomes &amp;; a bare & would make the file invalid XML.
  8. In that same input, https://www.example.com/ appeared twice and once more with #top at the end. Since the fragment is dropped, all three are the same URL; the tool keeps one and reports it: 2 URLs written. 2 duplicate URLs removed.
  9. With change frequency weekly and priority 0.8, two lines are added to every url element: <changefreq>weekly</changefreq> and <priority>0.8</priority>
  10. A URL on another host stops the tool. With https://blog.example.com/post on the second line: Line 2: all URLs must be on the same site (https://www.example.com); this line belongs to https://blog.example.com.
  11. A date that does not exist (2026-02-30) or a time without a time zone (2026-01-15T09:30:00) is rejected as well: Line 1: invalid date. Enter a real date as YYYY-MM-DD or in the form 2026-01-15T09:30:00+03:00.

Result: The three-URL file opens with the root element <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">; the URLs are written as <loc>https://www.example.com/</loc>, <loc>https://www.example.com/about</loc> and <loc>https://www.example.com/blog/first-post</loc>, with the dates 2026-11-20, 2026-01-15 and 2026-11-20. Tool note: 3 URLs written.

🗺️ XML Sitemap Generator

Free, no sign-up; your data stays in your browser.

Open the calculator →

How to read the result

A sitemap is a suggestion to the search engine. Google's documentation says that submitting a sitemap is merely a hint and does not guarantee that Google will download it or use it to crawl the URLs. The same page states that Google ignores the priority and changefreq values, and that it uses lastmod when the value is consistently and verifiably accurate; the value should reflect the last significant update to the page. Stamping today's date on every page each time the file is generated therefore achieves nothing. The location of the file sets its scope: under the protocol, /blog/sitemap.xml may list only URLs that start with /blog/, which is why the file is usually placed in the site root. Sites with more than 50,000 URLs, or more than 50 MB uncompressed, split the list across several files and gather those files in a sitemap index. An index may list up to 50,000 sitemaps, and according to Google's documentation the listed sitemaps must be on the same site as the index, in the same directory or lower. The tool produces a single urlset file; it does not create index files or gzip compression. You can tell Google about the file in three ways: the Sitemaps report in Search Console, the Search Console API, or a Sitemap line in robots.txt.

Common mistakes

  • Writing relative URLs. A path such as /about is invalid; every loc value must be a full URL that starts with the protocol and host.
  • Mixing protocols or hosts. http and https, www and non-www, and subdomains are different sites; under the protocol, every URL in a sitemap uses the sitemap's own protocol and host.
  • Leaving the ampersand unescaped. In URLs with a query string, & must be written as &amp;, otherwise the XML cannot be parsed.
  • Setting lastmod to today's date every day. A value that does not reflect a real change stops being a trustworthy signal; Google uses it only when it is consistently accurate.
  • Expecting priority and changefreq to control how often pages are crawled. The protocol defines them as hints, and Google ignores them.
  • Publishing a single file beyond 50,000 URLs or 50 MB. The list has to be split and a sitemap index used.
  • Putting the file in a subdirectory and listing the whole site. A sitemap covers only URLs below its own directory; placing it in the root avoids the problem.
  • Giving a time without a time zone. 2026-01-15T09:30:00 is not valid W3C Datetime; add Z or an offset such as +03:00.

Frequently asked questions

How many URLs can a sitemap contain?

Under the protocol, a single file may hold at most 50,000 URLs and must not exceed 50 MB (52,428,800 bytes) uncompressed. Google's documentation gives the same limits. Larger sites split the list and use a sitemap index.

What is a sitemap index file?

An XML file with the root element sitemapindex that lists the URLs of other sitemap files. It may contain up to 50,000 sitemaps. You then submit only the index file to the search engine instead of each sitemap separately.

How do I submit a sitemap to Google?

Google's documentation lists three ways: submit it in the Sitemaps report in Search Console, use the Search Console API, or add the line "Sitemap: https://www.example.com/sitemap.xml" to your robots.txt file. That line may be placed anywhere in the file.

Should I include priority and changefreq?

You do not have to. Both are optional in the protocol and count as hints, and Google's documentation says outright that it ignores them. The tool's default is to leave both out.

What format does lastmod use?

W3C Datetime: 2026-01-15 for a date alone, or 2026-01-15T09:30:00+03:00 for a full timestamp. The tool rejects dates that do not exist, such as 30 February, and times without a time zone.

How are URLs with accented or non-Latin characters written?

The protocol asks for URLs encoded as the web server expects them and for a UTF-8 file. The tool percent-encodes non-ASCII characters, so the path /café becomes /caf%C3%A9. Browsers show the same URL in readable form in the address bar.

Will a page listed in my sitemap definitely be indexed?

No. A sitemap tells the search engine which URLs you know about; it makes no promise that they will be crawled or indexed. Google's documentation describes submission as merely a hint.

The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.

Sources

Choose your cookie preference to continue

Records the site needs to work (theme, language, favourites) stay in your browser.

This site is free and funded by ads.

With your consent, Google Analytics cookies measure visits and Google AdSense cookies are used to show ads; the data is processed on Google servers abroad.

If you reject, the site works just the same.

Cookie Policy · KVKK notice