Lazo Lab Sign up

App 7: Your First Website with Flask / Build a guestbook website

Lesson 3 of 10

A base layout

Every page shares a header and footer. Put them in base.html once and have other pages extend it.

Key points

  • {% block content %}{% endblock %} marks the gap
  • {% extends "base.html" %} reuses it
  • Change the layout in one place
<!-- base.html -->
<header>My Site</header>
<main>{% block content %}{% endblock %}</main>

<!-- index.html -->
{% extends "base.html" %}
{% block content %}<p>Welcome!</p>{% endblock %}

Your turn

Create base.html and make index.html extend it.

Watch a video on thisOpens YouTube search results for “A base layout” in a new tab

Quiz · +10 XP

Why use a base template?

Log in to save progress and earn XP.