Concepts 🚀 Project 🧮 Labs
📚 Learn / Web & FastAPI / Jinja2 templates

Jinja2 templates

Server-side HTML rendering with {% extends %}, {% block %}, {{ var }}.

Code example

# base.html
<title>{% block title %}OpenBenchML{% endblock %}</title>

# notebook.html
{% extends 'base.html' %}
{% block title %}Notebook — OpenBenchML{% endblock %}
{% block content %}<h1>Notebook</h1>{% endblock %}

How it works

Jinja2 is a templating engine. Templates extend a base layout and override named blocks. Variables use `{{ var }}`; control flow uses `{% if %}`, `{% for %}`, `{% block %}`. The template is rendered server-side into a complete HTML string which is sent to the browser. This is faster and more SEO-friendly than client-side rendering (React/Vue) because the browser gets a complete page on the first byte.

🔍 Where this is used in OpenBenchML Every HTML page. base.html is the shell; 21 other templates extend it.