I can't seem to figure out the issue here but I am having trouble using a custom layout for a sitemap page I am creating.

site/content/pages/sitemap/sitemap.md:

title: Sitemap
content_type: xml
template: sitemap
layout: xml

themes/[themename]/layouts/xml.html:

<?xml version="1.0" encoding="UTF-8"?>
{{ template_content }}

themes/[themename]/templates/sitemap:

<urlset>etc xml stuff</urlset>

routes:

/sitemap.xml: sitemap

When viewing the front of the site (eg localhost:8000/sitemap.xml) I see the content (etc) but it is not using the custom xml layout, it's using the default layout. It doesn't appear to be reading the layout part of the sitemap.md

Can't see what I'm missing here?

Edit:

I was able to partially fix the problem, although I don't see why it works.

If i remove the route from the routes file, then when I access the page at /sitemap (i.e. without the .xml) it loads the correct file.

Why would adding a route to the routes file break the connection to the custom template?