Search⌘ K

Template Inheritance

Explore how to use Jinja template inheritance to avoid rewriting common components in Flask web templates. Understand creating a base template with blocks as placeholders and how child templates extend and replace these blocks with specific content, streamlining dynamic web page development.

Introduction #

Template inheritance is a compelling feature of Jinja that lets us reuse templates. Consider an example where we have two templates: home.html and about.html. Both of these files use the same CSS file called style.css. You can see the files and their outputs below.

home.html +

...