Answers.Body: <p>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 <a href="http://buildwithcraft.com/docs/config-settings#defaultTemplateExtensions" rel="nofollow">defaultTemplateExtensions</a> to it. (See a full explanation <a href="http://buildwithcraft.com/classreference/services/TemplatesService#findTemplate-detail" rel="nofollow">here</a>.)</p>
  
  <p>robots.txt does make a good use case for why we should append those extensions anyway, though. We shall consider it :)</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>We changed this behavior in Craft 2.2, so now a request to /robots.txt could resolve to a template called /robots.txt.twig. <a href="http://buildwithcraft.com/updates#build2579" rel="nofollow">http://buildwithcraft.com/updates#build2579</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-26T00:32:46.380Z
Answers.Text: If you are setting up sitemap.xml.twig
  `{% header "Content-Type: text/xml;" %}`
  `<?xml version="1.0" encoding="UTF-8" ?>`
Answers.UserDisplayName: David Rampersad
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-16T19:32:05.770Z
Answers.Text: The 2.2 update is great, and allows us to name things `robots.txt.twig`, `entries.json.twig`...However, we now unfortunately miss out on the `Content-type` detection that we would get if we had the templates names without the `.twig` on the end. Too much to ask? :)
Answers.UserDisplayName: Tim Kelty
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-16T20:50:03.893Z
Answers.Text: `.twig` files are always going to default to HTML. You can explicitly set the MIME type using the [{% header %}](http://buildwithcraft.com/docs/templating/header) tag though: `{% header "Content-Type: text/plain; charset=utf-8" %}`
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-28T21:40:21.503Z
Answers.LastActivityDate: 2014-09-02T18:57:08.103Z
Answers.LastEditDate: 2014-09-02T18:57:08.103Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I like to use <code>.twig</code> 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.</p>
  
  <p>For instance:</p>
  
  <ul>
  <li><code>robots.txt</code> works fine</li>
  <li><code>robots.txt.twig</code>, doesn't. The matching request is now <code>{siteUrl}/robots.txt.twig</code>, and I don't get the automatic <code>Content-Type</code> matching that happens when it is just <code>robots.txt</code>.</li>
  </ul>
  
  <p>I figure this just isn't currently supported, but I would be nice!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-08-28T20:53:03.177Z
Comments.Text: Curious... what's the use case for using a double extension?  i.e. Why not just use robots.twig?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-08-28T21:24:48.677Z
Comments.Text: Well, in the case of `robots.txt`, because it _has_ to be accessible from `/robots.txt`. So to use `robots.twig` you'd have to set up a route. And with the `.txt` in the template name, you get the `content-type` header automatically set.
Comments.UserDisplayName: Tim Kelty
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-02T18:57:41.250Z
Comments.Text: @TimKelty We made this possible in Craft 2.2. Updated my answer below!
Comments.UserDisplayName: Brandon Kelly
Tags: <templating>
Title: Include an extension in your template name, including ".twig" (e.g. robots.txt.twig)
ThreadText: # Include an extension in your template name, including ".twig" (e.g. robots.txt.twig)
  
  (Asked by: username_0 on 2014-08-28)
  
  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!
  
  **Tags:** templating
  
  > **Comments:**
  > **username_1**: Curious... what's the use case for using a double extension?  i.e. Why not just use robots.twig?  
  > **username_0**: Well, in the case of `robots.txt`, because it _has_ to be accessible from `/robots.txt`. So to use `robots.twig` you'd have to set up a route. And with the `.txt` in the template name, you get the `content-type` header automatically set.  
  > **username_2**: @username_0 We made this possible in Craft 2.2. Updated my answer below!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2014-08-28. Score: 2 | Accepted answer
  
  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](http://buildwithcraft.com/docs/config-settings#defaultTemplateExtensions) to it. (See a full explanation [here](http://buildwithcraft.com/classreference/services/TemplatesService#findTemplate-detail).)
  
  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>
  
  > **Comments:**
  > **username_0**: The 2.2 update is great, and allows us to name things `robots.txt.twig`, `entries.json.twig`...However, we now unfortunately miss out on the `Content-type` detection that we would get if we had the templates names without the `.twig` on the end. Too much to ask? :)  
  > **username_2**: `.twig` files are always going to default to HTML. You can explicitly set the MIME type using the [{% header %}](http://buildwithcraft.com/docs/templating/header) tag though: `{% header "Content-Type: text/plain; charset=utf-8" %}`  
  > **username_3**: If you are setting up sitemap.xml.twig `{% header "Content-Type: text/xml;" %}` `<?xml version="1.0" encoding="UTF-8" ?>`  
  
  ---
  
  