Examples

Jinja Template Inheritance

Building a Base Template

Jinja base template uses {% extends %} for site layouts.

Understanding Jinja Template Inheritance

Jinja template inheritance allows you to create a base HTML template and extend it to create more specific templates. This technique facilitates consistent site layouts and easier maintenance. The core mechanism of inheritance in Jinja is the {% extends %} statement, which is used to define a base template.

Creating a Base Template

To begin with template inheritance, you need a base template that contains the common structure for your site pages. Usually, this includes the doctype, header, footer, and common styles or scripts.

Previous
Mocking