0Pricing
Flask Academy · Lesson

Include Reusable Partials

Pull in navbars and footers with include.

Include Reusable Partials is a free Flask Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Flask Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Some Parts Are Shared, Not Page-Wide

A navbar or footer appears on many pages but is not the whole layout. For these chunks you reach for include instead of inheritance. 🧱

extends vs include

Use extends to inherit a full skeleton, but use include to drop a small reusable snippet into the current template at that spot.

The include Tag

The include tag pastes another template file right where you place it. The included file renders as if its markup were written inline.

{% include "navbar.html" %}

A Partial Is Just a Template

A partial is an ordinary template holding only a fragment, like a nav bar. Naming it _navbar.html signals it is meant to be included.

<nav><a href="/">Home</a></nav>

Include in Your Base

You can include a partial inside the base so every page that extends it gets the navbar automatically, with no repeated markup.

<body>
  {% include "navbar.html" %}
  {% block content %}{% endblock %}
</body>

Partials See the Context

An included partial can read the same variables as the page that includes it, so a navbar can show the logged-in user name.

{% include "navbar.html" %}

Pass Extra Context

You can hand a partial its own values with with, scoping variables so the snippet stays focused and predictable.

{% include "card.html" with context %}

Tolerate a Missing File

Add ignore missing so a missing partial is skipped silently instead of crashing the page render.

{% include "ads.html" ignore missing %}

Keep Partials Small

A good partial does one job: a footer, a flash message bar, a single card. Small, focused fragments are easy to reuse and reason about.

Organize Partials in a Folder

Group fragments under a partials subfolder and reference them by that path. It keeps full pages and reusable snippets clearly separated.

{% include "partials/footer.html" %}

Edit Once, Update Everywhere

Fix the footer in its partial and every page that includes it updates together. That single edit is exactly why include exists. ✨

Quick Check

When should you reach for include instead of extends?

Recap: Partials

Use include to embed small shared snippets like navbars and footers. Keep them tiny, folder-organized, and edit them in one place. 🎯

Frequently asked questions

Is the “Include Reusable Partials” lesson free?

Yes — the full text of “Include Reusable Partials” is free to read here on the web, and the Flask Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Flask Academy course, upgrade to CoddyKit PRO.

What will I learn in “Include Reusable Partials”?

Pull in navbars and footers with include. You practise Flask Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Flask Academy?

No prior experience is required. Flask Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Include Reusable Partials” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Flask Academy lesson?

Yes. Every Flask Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Define a Base Template with Blocks
  2. Extend the Base in Child Pages
  3. Include Reusable Partials
  4. Macros for Repeated Markup
← Back to Flask Academy