Answers.Body: <p>Yes, prefixing a template's filename with an underscore does what it says on the box – any underscored template will be excluded from route mapping.</p>
  
  <p>A typical use case is to use underscores for partials or wrappers, e.g. "_mainmenu.html" or "_baseTemplate.html" – essentially any template that doesn't make any sense to load up or access directly in the browser via that template's path.</p>
  
  <p>This isn't a mandatory thing, but a good practice.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-01T15:11:25.947Z
Answers.Text: It actually is required if you want to prevent URI to tempate routing for that URI (→ [routing case 6](http://buildwithcraft.com/docs/routing)).
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-01T15:20:10.203Z
Answers.Text: Good point, @carlcs.
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-29T06:45:06.590Z
Answers.Text: It's an old topic, but I found it since I was looking for the meaning of prefixing underscores for folder names and I could only find this topic. 
  So I might be asking a dumb question, if so, my sincere apologies :-), but I'm wondering: what does prefixing underscores for folder names do? Does that mean that all templates in that folder are being excluded from route mapping so you don't need a prefixed underscore for all templates inside that folder? 
  I now do both: prefixing my folder and prefixing my template name, but I'm wondering if that's too much...
Answers.UserDisplayName: Jan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-29T22:32:48.270Z
Answers.Text: @Jan Right, if you prefix a folder name w/ an underscore, everything inside that folder (both templates and subfolders) will be excluded from routing. Hence, it’s not necessary to underscore a template sitting in an underscored folder.
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-03T11:04:37.833Z
Answers.Text: Thanks for the answer, now I know for once and for all :-) !
Answers.UserDisplayName: Jan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-29T13:18:13.173Z
Answers.Text: Is there any way to override this behaviour on a local environment? (We have Commerce email templates in an _email folder and sometimes need to test them locally, which means renaming the folder, then renaming it back again)
Answers.UserDisplayName: James Greig
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-01T15:03:52.863Z
Answers.LastActivityDate: 2015-04-01T15:03:52.863Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>More of a question than problem; I see this often - templates that start with an underscore. For example, <code>_entry.html</code>.</p>
  
  <p>Reading the Craft docs:</p>
  
  <blockquote>
    <p>Note that if any of the URI segments begin with an underscore ('_'), Craft will return a 404, since template path segments that begin with an underscore are considered "hidden" from direct access</p>
  </blockquote>
  
  <p>I guess I'm confused as to what I am hiding <em>from</em>. Is it so I can't directly browse right to the full path of that template?</p>
  
  <p><code>mysite.com/something/something/_template.html</code></p>
  
  <p>If you move the craft folder outside of the site root, I can't really get to that file can I? It just isn't obvious to me (yet) what the benefit is and when/where/why I need to start a template with and underscore.</p>
  
  <p>Thank you!</p>
  
Tags: <templating><routes>
Title: Routing templates thats start with an underscore
ThreadText: # Routing templates thats start with an underscore
  
  (Asked by: username_0 on 2015-04-01)
  
  More of a question than problem; I see this often - templates that start with an underscore. For example, `_entry.html`.
  
  Reading the Craft docs:
  
  > Note that if any of the URI segments begin with an underscore ('\_'), Craft will return a 404, since template path segments that begin with an underscore are considered "hidden" from direct access
  
  I guess I'm confused as to what I am hiding *from*. Is it so I can't directly browse right to the full path of that template?
  
  `mysite.com/something/something/_template.html`
  
  If you move the craft folder outside of the site root, I can't really get to that file can I? It just isn't obvious to me (yet) what the benefit is and when/where/why I need to start a template with and underscore.
  
  Thank you!
  
  **Tags:** templating, routes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-04-01. Score: 8 | Accepted answer
  
  Yes, prefixing a template's filename with an underscore does what it says on the box – any underscored template will be excluded from route mapping.
  
  A typical use case is to use underscores for partials or wrappers, e.g. "\_mainmenu.html" or "\_baseTemplate.html" – essentially any template that doesn't make any sense to load up or access directly in the browser via that template's path.
  
  This isn't a mandatory thing, but a good practice.
  
  > **Comments:**
  > **username_2**: It actually is required if you want to prevent URI to tempate routing for that URI (→ [routing case 6](http://buildwithcraft.com/docs/routing)).  
  > **username_1**: Good point, @username_2.  
  > **username_3**: It's an old topic, but I found it since I was looking for the meaning of prefixing underscores for folder names and I could only find this topic.  So I might be asking a dumb question, if so, my sincere apologies :-), but I'm wondering: what does prefixing underscores for folder names do? Does that mean that all templates in that folder are being excluded from route mapping so you don't need a prefixed underscore for all templates inside that folder?  I now do both: prefixing my folder and prefixing my template name, but I'm wondering if that's too much...  
  > **username_1**: @username_3 Right, if you prefix a folder name w/ an underscore, everything inside that folder (both templates and subfolders) will be excluded from routing. Hence, it’s not necessary to underscore a template sitting in an underscored folder.  
  > **username_3**: Thanks for the answer, now I know for once and for all :-) !  
  > **username_4**: Is there any way to override this behaviour on a local environment? (We have Commerce email templates in an _email folder and sometimes need to test them locally, which means renaming the folder, then renaming it back again)  
  
  ---
  
  