Articles / What is with the underscore in twig template filenames?
Jan 27. 2019 · by Helge Sverre

What is with the underscore in twig template filenames?

Quick one.

In Craft CMS you can name your template files whatever you want, about.twig, super-banana.twig, etc.

You can then enter that filename into the url to load that template directly:


This is useful if you need to create a page that doesn't have to be edited via the Craft CMS control panel, but rather pulls in content from external sources or other sections (ex: blog archive page, blog index, the Homepage).

If you however prefix the filename with an underscore (ex: _about.twig), the template cannot be loaded directly via the URL.

You can change the prefix that is used to indicate that a template is private, by changing the general config option privateTemplateTrigger to something like "private_" to make it super obvious.

And that's pretty much all there is to it.

Helge Sverre Hessevik Liseth

Book 1:1 help from me on CodeMentor, get expert advice and help with CraftCMS, Flutter or Laravel.

  • Flutter
  • CraftCMS
  • PHP
  • VueJS
Book session