Does anyone know how to make Craft by default use .twig extensions. It helps IDEs better understand Twig blocks. I have tried .twig and .html.twig but it doesn't appear to work by default.
I don't want to set up special configs for every template.
Does anyone know how to make Craft by default use .twig extensions. It helps IDEs better understand Twig blocks. I have tried .twig and .html.twig but it doesn't appear to work by default.
I don't want to set up special configs for every template.
Craft does already support .twig
as a template file extension option by default (see the defaultTemplateExtensions config setting docs). If you want to allow .html.twig
as well, just open craft/config/general.php and add this to the config array:
'defaultTemplateExtensions' => array('html', 'twig', 'html.twig'),
(Note that this will only affect front-end templates. The Control Panel is locked to .html
and .twig
for plugins.)
Why do you want to use a .twig extension? The official Twig documentation uses .html, P&T use .html in the Craft codebase and in the Craft documentation. I would say .html is the standard for Craft template files.
Most editors can be configured to load the Twig language / syntax parser for files with other extensions then .twig
Configuration instructions for some popular editors and IDEs:
text.html.twig
language)files.associations
setting){% include %}
tags etc., the two are totally interchangeable; there are no drawbacks to using .twig, in my opinion.
Commented
May 19, 2016 at 12:05
.twig
in Commerce though, just to mess with you :)
Commented
May 19, 2016 at 14:10