A sitemap is a hint, not an instruction
What a sitemap does is help discovery. It tells a crawler that a set of URLs exists, which matters most for pages that are hard to reach by following links — a new post before anything links to it, a deep archive, a page reachable only through a search form. That is the whole mechanism.
What it does not do is decide indexing. Listing a URL does not oblige an engine to crawl it, does not oblige it to index it once crawled, and does not affect where it ranks. Pages get left out for reasons the sitemap has no bearing on: thin or duplicated content, a canonical pointing elsewhere, a noindex tag, a crawl budget spent on more valuable URLs. When Search Console reports "Discovered — currently not indexed", the sitemap did its job and the decision was made downstream.
The corollary is that a sitemap should list only URLs you want indexed as-is: canonical, 200-returning, not redirected, not noindex. Every URL in the file that does not meet that description turns into a warning in Search Console and weakens the file as a signal of what you consider important.
lastmod, changefreq and priority
Of the three optional elements, one is used and two are not.
lastmod is read, on the condition that it is consistently accurate. Google has been explicit that it is used when trusted and disregarded when it is not, and the fastest way to lose that trust is to stamp every URL with today's date on every build. That makes the field pure noise and the whole file's dates worthless. If your build cannot tell you when a page's content genuinely last changed, omitting the field is a better answer than guessing — which is why it defaults to omitted here.
changefreq and priority are ignored by Google, and treated as at most a weak advisory by Bing. priority in particular is widely misread as importance relative to other sites; it was only ever defined as relative importance within your own sitemap, and setting everything to 1.0 conveys exactly as much as setting everything to 0.5, which is nothing. Both options are offered above because the schema permits them and some tooling expects them, not because filling them in will change anything.
Limits, splitting and encoding
A single sitemap holds at most 50,000 URLs and 50 MB uncompressed. Past either limit, split into sitemap-1.xml, sitemap-2.xml and so on, and list those files in a <sitemapindex>. An index can itself hold 50,000 sitemaps, so the ceiling is not one you reach by accident. Files may be gzipped and served as .xml.gz; the 50 MB limit applies to the uncompressed size.
Every URL must be on the same host and protocol as the file itself — http:// and https://, and www and bare, are all distinct hosts as far as this rule is concerned. The five XML entities are escaped for you, which matters mostly for & in query strings, since an unescaped ampersand makes the file invalid and the whole sitemap gets rejected rather than the one bad line.
Getting it read
Put the file at /sitemap.xml, add a Sitemap: line to robots.txt so any crawler finds it without being told, and submit it in Google Search Console and Bing Webmaster Tools. Submission also buys you the reporting: which URLs were read, which were skipped and why.
Beyond the basic URL sitemap there are extensions for images, video and news, plus xhtml:link entries for hreflang alternates that let you declare language versions in the sitemap instead of in every page head. None of them are generated here — this tool wraps a list of URLs and nothing more, and if you need those extensions you are past the point where pasting a list into a text box is the right workflow.
Questions people ask
I submitted a sitemap and my pages still are not indexed.
That is the expected behaviour, not a failure. The sitemap made the URLs discoverable; whether they get indexed depends on content quality, internal linking, canonical tags, noindex directives and crawl budget. Use the URL Inspection tool in Search Console on a specific page — it names the actual reason, which is usually a canonical pointing elsewhere or a page judged too thin to be worth storing.
Should I put today as lastmod for every page?
No. An engine that sees every URL claim it changed today learns that your dates carry no information and stops using them. The field is only worth including when it reflects a real content change. If you cannot produce that date, leave it out.
Does setting priority to 1.0 help?
No. Google ignores priority entirely. Even under the original specification it only expressed relative importance inside your own sitemap, so making every URL 1.0 was always equivalent to making them all 0.5.
Can I include URLs with query strings?
Yes, but include only the canonical form. Parameter variants that serve the same content should not each get their own entry — pick the one your canonical tag names. The depth calculation used for the priority option ignores the query string and looks only at the path.
Do I need a sitemap at all?
A small site with clean internal linking gets crawled thoroughly without one. It earns its place when discovery is genuinely hard: thousands of pages, deep archives, frequently added content, or pages with few inbound internal links. It is cheap enough that having one is rarely the wrong call.