A sitemap can contain the right page address and still fail to parse because an ampersand was copied into XML unchanged. The fix is to escape the URL when writing the XML, while keeping the original address in your URL list. This guide uses one query-string example to show the correct output, a double-escaping mistake and the separate role of percent-encoding.
Keep the browser URL and XML representation separate
Suppose a fictional shop has deliberately chosen this public, indexable catalog page as its canonical URL:
https://example.com/catalog/?type=tea®ion=uk
Here, the ampersand separates two query parameters: type=tea and region=uk. In XML source, that same character needs an entity reference. The Sitemaps protocol escaping rules specify & for an ampersand. A reader of the XML recovers the original & character from that representation.
Do not include every filtered or campaign URL merely because it can be escaped. Decide which page addresses belong in search first. If you are unsure whether a parameter is part of the preferred page, review the guide to canonical URLs and tracking parameters.
Generate the entry from the original address
Use the XML Sitemap Generator with the URL above, copied as a browser address with a plain ampersand.
- Paste the address into Paste your URLs (one per line).
- Choose Omit changefreq under Change frequency and Omit priority under Priority.
- Choose No lastmod under Last modified. This example has no verified page-update date.
- Click Generate Sitemap. For this single input, check that the report shows one URL, zero invalid lines skipped and zero duplicates removed.
- Review the generated text, then use Download sitemap.xml.
The tool formats a supplied URL list; it does not crawl the site, check HTTP responses or inspect canonical tags. An accepted input is not evidence that its page exists or should be indexed.
Check the ampersand inside the loc element
With those settings, the expected file is:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/catalog/?type=tea&region=uk</loc>
</url>
</urlset>
Inspect the file as source text: the separator is written & inside <loc>. Do not replace it with a raw ampersand to make the source resemble the address bar. XML escaping preserves the address through the XML layer.
Watch for a second round of escaping
If you paste a URL already containing & into this generator, it escapes the ampersand again. The output then contains &amp;. After XML parsing, the resulting URL still contains the literal text &, which is not the original two-parameter address.
Return to the original URL list and regenerate. Avoid repeatedly replacing ampersands throughout a finished XML document; a blanket replacement can damage references that were already correct.
Do not substitute percent-encoding for XML escaping
MDN explains percent-encoding, including %26 for an ampersand. That operates at the URL layer. For an ordinary query string, changing our separator to %26 produces:
https://example.com/catalog/?type=tea%26region=uk
This expresses a single type value of tea®ion=uk, rather than a separate region parameter. It is a different request. Keep necessary URL encoding within parameter values, then apply XML escaping when placing the complete address in the sitemap.
Validate the file that your server actually serves
Open the downloaded file with an XML-aware editor or parser and check for parse errors. Confirm that the parsed location matches the original address, including both parameters. After deployment, inspect the sitemap URL itself: it should return the intended XML, not a login screen or HTML error page.
Google recommends absolute, preferred canonical URLs in sitemaps and requires entity escaping for XML values. Check the Sitemaps report after submission for processing errors. Passing XML validation does not prove page eligibility or guarantee indexing. For the broader URL-list and publishing workflow, see creating a sitemap for a small website.