'Flask: Include common template to multiple blueprints

How could I implement a common template to be included in two Flask blueprints? I am trying to create the following structure in my application:

 app
  +-- bp
  |    +-- hello
  |    |   +-- templates
  |    |   |    +-- hello
  |    |   |        +-- hello.html
  |    |   +-- routes.py
  |    +-- world
  |        + etc
  +-- templates
       +-- common_incl.html

in hello.html, I try to include another file by {% include '/templates/common_incl.html' %} but I always get a TemplateNotFound exception.

I would not like to expose the common_incl.html in static folder, as it isn't static but has Jinja variables expressions.



Solution 1:[1]

Re-reading https://flask.palletsprojects.com/en/2.0.x/blueprints/#templates might provide some guidance.

Depending on the nature of your application (and your blueprints) either put the base templates in the application's templates folder, or use a third blueprint that does nothing but hold common templates for your two templates.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dave W. Smith