Deploying Flask App to Heroku - Template Not Found


I'm developing my first app with Flask and deploying to Heroku. Below is the error message I get locally and on Heroku. Also can be seen here:

jinja2.exceptions.TemplateNotFound TemplateNotFound: home.html

Longer version of the error here:

File "/app/.heroku/python/lib/python2.7/site-packages/flask/",
line 61, in get_source raise TemplateNotFound(template)
TemplateNotFound: home.html

Here's an overview of the app:

Directory: /helloflask


web: python



import os
from helloflask import app
port = int(os.environ.get('PORT', 5000))'', port=port, debug=True)

Directory: /helloflask/helloflask

from flask import Flask, render_template
app = Flask(__name__)
import helloflask.views

from helloflask import app
from flask import Flask, render_template
def home():
return render_template('home.html')

Directory: /helloflask/templates

home.html = a standard HTML file

Directory: /helloflask/static/css

main.css = standard CSS file

I've scoured the Interwebs for an answer with no luck. Anyone seen this before?

1/21/2016 5:23:01 PM

Accepted Answer

Try creating the templates folder at the root of the application /templates and see if that fixes the problem. I think you can set the templates folder in Flask, just can't find it now.

Also, you might like the github repo on flask deployment on Heroku.

Also checkout this SO Post on folder structure - flask blueprint template folder You may want to use Flask Blueprints, if you prefer to keep templates under helloflask.

I don't use Flask on Heroku, so have not verified this setup. Hope this helps.

5/23/2017 12:23:28 PM

The templates folder should be a part of the package as your app. Move it into /helloflask/helloflask.

See #2 from

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow