Sitemap cookbook code doesn't work on Kirby 2.4.1

Hey there,

I implemented the exact code and steps found in the cookbook for easy sitemap generation.

But instead of displaying the sitemap as xml kirby uses the default template and renders the body but leafs the header blank, so that no css is applied and utf-8 is not used as well.

any ideas???

You probably made a mistake, maybe a typo in the filename.

Make sure the name of the content file and the name of the template match exactly, i.e. xmlsitemap.txt and xmlsitemap.php

Yes, I double checked the typo of the filenames a 100 times, they are correct.

one more thing i noticed:
accessing the sitemap just like that http://yourdomain.com/sitemap
=> renders a page using the default template

accessing the sitemap with http://yourdomain.com/sitemap.xml
=> renders a php 404 error “Not found - The requested resource /sitemap.xml was not found on this server.”

ahhhh got it working.

I have a site using different languages!!!
So I hade to use the template-name followed by the language code in the content folder!!!
like:

xmlsitemap.en.txt

maybe you would like to add a hint in the cookbook. Could be helpful for others, got me puzzeling for some time now…
thanks anyway!

That’s what I was just going to ask…

… and I’ve updated the documentation.

1 Like

unfortunately the http://yourdomain.com/sitemap.xml error stays

on localhost: => php error 404

Not Found
The requested resource /sitemap.xml was not found on this server.

on server:
the custom 404 page (error.php template) gets rendered

For the xml extension to work, you either have to rename the folder to xmlsitemap and add an additional template xmlsitemap.xml.php template (see content representations, or use a route. In Kirby 1, extensions were ignored, in Kirby 2.4.1 they are not.

Edit: However, I don’t see much sense in two URLs rendering the same content, unless you reroute one to the other.

There are also a couple of plugins that make sitemap creation easier, especially on multi-language sites: https://github.com/jenstornell/kirby-plugins/issues?utf8=✓&q=sitemap