In short
Ahrefs flags "Sitemap has syntax error" when a sitemap isn't valid XML or doesn't follow the sitemap protocol. Search engines may ignore part or all of it. The usual causes are an unescaped & in a URL, blank lines or PHP warnings before the XML declaration, a wrong namespace, and files cut off mid-way. Open the sitemap in a browser to see the first error, fix its source, and revalidate.
XML is strict. One unescaped character can make a whole sitemap unreadable.
Common errors
| Error | Example | Fix |
|---|---|---|
| Unescaped ampersand | ?a=1&b=2 |
Write & in XML |
Content before <?xml |
Blank line or PHP warning at the top | Remove whitespace from theme or plugin files; fix the warning |
| Missing or wrong namespace | No xmlns on <urlset> |
Use http://www.sitemaps.org/schemas/sitemap/0.9 |
| Unclosed tags | File cut off mid-way | Fix the generator's timeout or memory limit |
| Non-UTF-8 characters | Accented characters in URLs | Encode as UTF-8 and percent-encode URLs |
A valid minimal sitemap
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2026-12-01</lastmod>
</url>
</urlset>Platform tips
WordPress: the classic cause is whitespace or a PHP notice printed before the XML, from a theme's functions.php or a plugin. Turn plugins off one at a time to find it.
Shopify, Webflow and Wix: automatic sitemaps are valid. Errors mean a custom sitemap was uploaded; fix or remove it.
Custom builds: build the XML with a library instead of joining strings, so escaping is automatic.
This guide isn't affiliated with or endorsed by Ahrefs.
Related issues
Sources and references
sitemaps.org, Sitemaps XML format
Google Search Central, Build and submit a sitemap

About the author
Nazmul Nikhil
Head of SEO & Assistant Manager, Digital Marketing at Notionhive
SEO and AI search consultant in Dhaka, Bangladesh, helping small and mid-size businesses in the USA, UK, Australia and Canada.



