Include an extension in your template name, including ".twig" (e.g. robots.txt.twig) I like to use .twig for my templates for easy syntax switching, but it doesn't seem to work when my template requires an extension as part of its name.

For instance:


robots.txt works fine
robots.txt.twig, doesn't. The matching request is now {siteUrl}/robots.txt.twig, and I don't get the automatic Content-Type matching that happens when it is just robots.txt.


I figure this just isn't currently supported, but I would be nice!
This is because right now, if your template path includes an extension, Craft assumes that you’re explicitly providing the full template path, and won’t try appending the defaultTemplateExtensions to it. (See a full explanation here.)

robots.txt does make a good use case for why we should append those extensions anyway, though. We shall consider it :)

UPDATE

We changed this behavior in Craft 2.2, so now a request to /robots.txt could resolve to a template called /robots.txt.twig. http://buildwithcraft.com/updates#build2579