← Flask learning pathFlask · Module 3 of 10
Templates with Jinja2
Render dynamic HTML using Jinja2 templates.
📖 Key ideas
- Put templates in templates/ folder.
- render_template("index.html", name=name).
- {{ name }} prints; {% for %} and {% if %} control logic.
- Inheritance with {% extends "base.html" %} and {% block %}.
- Static files go in static/; link with url_for("static", filename="style.css").
💡 Real-life example: Jinja2 is a mail-merge: one letter design, filled with each person's details.
Jinja2Template engine used by Flask
render_templateRenders a template with data
blockReplaceable area in a base template
static/Folder for CSS, JS, images