Fix “Namespace prefix image on image is not defined” error
605
10

Dec 04·Quick read
Fix “Namespace prefix image on image is not defined” error

Fix “Namespace prefix image on image is not defined” error

This weekend I was working on fixing my sitemap.xml generator.

I overhauled everything, and somewhere along the road, I removed something that broke my sitemap parsing, resulting in an error:

Namespace prefix image on image is not defined

I had multiple issues with my generator, so it wasn't instantly clear what was causing this particular issue. However, it turned out that the fix was simple and that the urlset was simply definitions for the image tag (duh - the error message says exactly that).

So this is the breaking version of my urlset declaration:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
// ...
</urlset>

As you can see it includes the xmlns but not the xmlns:image.

So the fix is super easy, you just need to provide the definitions as demonstrated below and that should fix your issue.

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
// ...
</urlset>

Hope this helps and if you have any questions, feel free to drop them in the comments below or reach out on Twitter @scottagirs. 🙌🏼

#
seo
#
errorFix

Discussions