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.
– Mats Mikkel Rummelhoff
May 19 '16 at 12:05
.twig in Commerce though, just to mess with you :)
– Brandon Kelly
May 19 '16 at 14:10
<for></for>. Trying to find a fix for this as it makes development a bit frustrating.
– Bonk
Apr 03 '17 at 14:45