<p>Under the PhpStorm preferences, go Editor->File Types->Twig and add <code>*.html</code> as a Registered Pattern.<img src="https://i.sstatic.net/WP3hz.jpg" alt="enter image description here"></p>

CC BY-SA 3.0
2015-06-15T15:31:31.630Z
Yea, I was hoping there was some way to do it w/o globally interpreting `.html` as Twig. I guess there's no downside, other than it just feels wrong.
Garrett
CC BY-SA 3.0
2015-07-19T19:21:27.167Z
The only problem with this is that it re-assigns it from HTML files. So when you use html files again in another project you will have to switch it back. FYI.
mattl
CC BY-SA 4.0
2019-04-02T07:04:38.283Z
You can solve this by adding *?html as a filetype. That way, everything that ends with .html will also get syntax highlighting without breaking regular html support.
Bert H
CC BY-SA 3.0
2015-06-12T19:21:49.887Z
2015-06-12T19:21:49.887Z
Brad Bell
<p>Even easier way… Just add <code>.html.twig</code> to <code>defaultTemplateExtensions</code> and update your template file extension to <code>.html.twig</code>. PHPStorm will pick up both html and twig syntax highlighting.</p>

<pre><code>&lt;?php

/**
 * General Configuration
 *
 * All of your system's general configuration settings go in here.
 * You can see a list of the default settings in craft/app/etc/config/defaults/general.php
 */

return array(
    'defaultTemplateExtensions' =&gt; array('html.twig', 'html'),
);
</code></pre>

CC BY-SA 3.0
2016-09-15T06:31:06.170Z
2016-09-15T06:31:06.170Z
Leevi Graham
<p>Instead of adding <code>*.html</code> as a registered Twig patter, I use <code>*?html</code>.  Seems to work just fine and I don't have to switch back and forth.</p>

<p>On the flip side, Twig support in PhpStorm seems to contain all the HTML support as well, so other than feeling wrong (which it does), there may be no downside to just switching it over to Twig.</p>

CC BY-SA 4.0
2016-01-21T23:38:39.933Z
2018-11-14T18:27:01.367Z
2018-11-14T18:27:01.367Z
mcmurphy
<p>Does anyone know of a way to instruct PHPStorm to treat Craft templates as Twig files, without globally assigning all <code>.html</code> files to be interpreted as Twig? Since Craft templates don't use the <code>.twig</code> extension, PHPStorm thinks they're HTML.</p>

<p>On that note, why doesn't Craft use .twig extensions? I assume P&amp;T doesn't want to scare away users who are comfortable with HTML but not Twig?</p>

CC BY-SA 3.0
2015-06-12T17:30:50.477Z
You can use the .twig extension with Craft if you want to. I do, and syntax highlighting (I use Sublime though) is the main reason.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-06-12T17:49:18.967Z
I would also assume that any worthwhile twig filter is also going to highlight html properly as well, so I don't see any reason not to interpret all `.html` files as HTMLTwig files. Besides, I believe you can set it on a project basis (although don't ask me how — but might be worth looking into).
Douglas McDonald
CC BY-SA 3.0
2015-06-15T15:32:18.300Z
I wish you could set it on a per-project basis, but I can't find any way to do that.
Garrett
CC BY-SA 3.0
2015-06-16T15:47:58.467Z
Haven't tested it, but the docs seem to suggest that you can specify filetypes on a per-project basis. See [Project and IDE settings](https://www.jetbrains.com/phpstorm/help/project-and-ide-settings.html) and [Creating and registering Filetypes](https://www.jetbrains.com/phpstorm/help/creating-and-registering-file-types.html)
Douglas McDonald
<templating>
Twig syntax highlighting in PHPStorm?
# Twig syntax highlighting in PHPStorm?

(Asked by: username_0 on 2015-06-12)

Does anyone know of a way to instruct PHPStorm to treat Craft templates as Twig files, without globally assigning all `.html` files to be interpreted as Twig? Since Craft templates don't use the `.twig` extension, PHPStorm thinks they're HTML.

On that note, why doesn't Craft use .twig extensions? I assume P&T doesn't want to scare away users who are comfortable with HTML but not Twig?

**Tags:** templating

> **Comments:**
> **username_1**: You can use the .twig extension with Craft if you want to. I do, and syntax highlighting (I use Sublime though) is the main reason.  
> **username_2**: I would also assume that any worthwhile twig filter is also going to highlight html properly as well, so I don't see any reason not to interpret all `.html` files as HTMLTwig files. Besides, I believe you can set it on a project basis (although don't ask me how — but might be worth looking into).  
> **username_0**: I wish you could set it on a per-project basis, but I can't find any way to do that.  
> **username_2**: Haven't tested it, but the docs seem to suggest that you can specify filetypes on a per-project basis. See [Project and IDE settings](https://www.jetbrains.com/phpstorm/help/project-and-ide-settings.html) and [Creating and registering Filetypes](https://www.jetbrains.com/phpstorm/help/creating-and-registering-file-types.html)  

---

## 3 answers

### Answer by username_3 on 2015-06-12. Score: 15

Under the PhpStorm preferences, go Editor->File Types->Twig and add `*.html` as a Registered Pattern.![enter image description here](https://i.sstatic.net/WP3hz.jpg)

> **Comments:**
> **username_0**: Yea, I was hoping there was some way to do it w/o globally interpreting `.html` as Twig. I guess there's no downside, other than it just feels wrong.  
> **username_4**: The only problem with this is that it re-assigns it from HTML files. So when you use html files again in another project you will have to switch it back. FYI.  
> **username_5**: You can solve this by adding *?html as a filetype. That way, everything that ends with .html will also get syntax highlighting without breaking regular html support.  

---

### Answer by username_6 on 2016-09-15. Score: 4

Even easier way… Just add .html.twig to defaultTemplateExtensions and update your template file extension to .html.twig. PHPStorm will pick up both html and twig syntax highlighting.
 array('html.twig', 'html'),
);


---

### Answer by username_7 on 2016-01-21. Score: 2

Instead of adding `*.html` as a registered Twig patter, I use `*?html`. Seems to work just fine and I don't have to switch back and forth.

On the flip side, Twig support in PhpStorm seems to contain all the HTML support as well, so other than feeling wrong (which it does), there may be no downside to just switching it over to Twig.


---

