Jinja2 code not recognised in HTML files.


Coming from Atom I was very easily able to write Jinja2 code inside a HTML file and have it render no problems. I would like to be able to do the same thing with PyCharm but can't work out how. I'm building a web app with Python, Flask and would like to include some Jinja code but its not recognized in any file type except for its own *.jijnja2 extension. I could convert all my html templates to .jinja2 but i would rather keep the html templates. 

If I go to settings, Languages and Frameworks, Python Template Languages, Jinja2 is selected as the Template language already with Template file types consisting of CSS, HTML, XHTML, and XML. HTML is there so why isn't it recognized? 

Any clues as to what I'm doing wrong or what I need to change? File Types perhaps?



works fine for me if Jinja2 is selected as the Template language for HTML in Languages & Frameworks | Python Template Languages

Where is the HTML file located? Please make sure that neither of its parent folders (including project root directory) are marked as Resource root. Also, do you have any custom plugins installed?


I had the same problem and it was indeed because a parent directory was marked as Resource Root. Thanks, Elena!


Please sign in to leave a comment.