How to detect debug mode in jinja?

When you run your flask application with app.run(debug=True), you can also just check the config object like so:

{% if config['DEBUG'] %}
    <h1>My html here</h1>
{% endif %}

use context processors

To inject new variables automatically into the context of a template, context processors exist in Flask. Context processors run before the template is rendered and have the ability to inject new values into the template context. A context processor is a function that returns a dictionary. The keys and values of this dictionary are then merged with the template context, for all templates in the app:

@app.context_processor
def inject_debug():
    return dict(debug=app.debug)

now debug variable accessible in templates.