Is there a way to use page() and specify which representation you want?
More specifically, if I had a /sitemap page and it has sitemap.txt and sitemap.xml.txt within it, is it possible to specify which representation I want to return in a Kirby Route?
Aside from redirection, it’s unclear to me how I could map something like example.com/foo-bar-sitemap.xml to actually show content from example.com/sitemap.xml. Similar problem for other representations like json api representations.
You would probably just create them either in your page controller, or page model - e.g., you would create an as_xml() or as_json() method that simply returns the page data you need in the appropriate format.
If there is a template for that representation, you could also load the template in routes (using tpl::load). But that only makes sense if you need that template for other purposes. Other than that, I’d also use methods that return your content in the appropriate format as already suggested by @luxlogica. You can also do things like this: