nexuspolaris Posted May 9 Posted May 9 Hi everyone, I’m running into a persistent issue when trying to serve a sitemap in ProcessWire via a custom sitemap-xml.php template. When I visit the page at /sitemap.xml, the browser shows this error: error on line 1 at column 50: Space required after the Public Identifier I’ve double-checked that the output starts with the proper XML declaration: header("Content-Type: application/xml; charset=UTF-8"); echo '<?xml version="1.0" encoding="UTF-8"?>'; Despite that, the error still shows up. The page is returning XML generated dynamically using httpUrl, and there might be other elements or layout markup leaking into the response. I suspect it could be related to BOM characters, extra whitespace before the <?php tag, or ProcessWire wrapping the output with a layout file like _main.php. I’ve tried setting return renderSitemapXML(); instead of echoing it, and ensured htmlspecialchars(..., ENT_QUOTES | ENT_XML1, 'UTF-8') is used in <loc> elements. Still no luck. Any advice on how to completely prevent PW from rendering the full HTML layout and just serve a clean XML output? Thanks in advance!
taotoo Posted May 9 Posted May 9 While I've never encountered that particular error, I have solved other ones by removing empty lines from beneath the closing php tag in my ready.php file.
virtualgadjo Posted May 10 Posted May 10 19 hours ago, nexuspolaris said: Any advice on how to completely prevent PW from rendering the full HTML layout and just serve a clean XML output? Hi, if you're using markup region and thus append the _main.php file to tour template, just go to your sitemap model config and check this checkbox (files tab) to prevent appending the full html thing around your xml 🙂 have a nice day 1
WilliamClayton Posted May 16 Posted May 16 On 5/10/2025 at 1:03 PM, virtualgadjo said: Hi, if you're using markup region and thus append the _main.php file to tour template, just go to your sitemap model config and check this checkbox (files tab) to prevent appending the full html thing around your xml 🙂 have a nice day Thank you so much, you saved my day.
virtualgadjo Posted May 16 Posted May 16 37 minutes ago, WilliamClayton said: Thank you so much, you saved my day. very glad to hear this, processwire saves mine so often 😀 heva a nice day
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now