Skip to main content

Templates for Flasks

Flask templates are Jinja files that mix HTML with placeholders, loops and conditions, rendered on the server with render_template. They sit between your view functions and the browser, turning Python data into finished pages, and they support inheritance so layouts such as headers and footers are written only once.

Stage: Quickstart · Part of the Flask roadmap · Last reviewed 19 November 2026

What to learn in Templates

Templates interview questions

Why does Jinja autoescape variables and when would you disable it?

Autoescaping converts characters such as angle brackets into HTML entities so user input cannot inject scripts into the page. You should disable it only for content you have already sanitised, using the safe filter or Markup, because switching it off for raw input creates a cross-site scripting hole.

How does template inheritance work in Flask?

A base template defines named block sections. A child template starts with an extends tag pointing to the base and fills in only the blocks it needs to change. This keeps navigation, styles and footers in one file instead of repeating them on every page.

Where Templates fits in the Flask roadmap

Templates belongs to the Quickstart stage (beginner level), which takes about 17 hours. Your first app.

Back to the full Flask roadmap