Skip to content

Including Partials

Partials are reusable template fragments.

Examples:

  • navbars
  • footers
  • alerts
  • “card” components
diagram include and extends solve opposite problems mermaid
extends is about a page fitting into a layout: the base is in charge and the child fills its holes. include is about dropping a fragment into the place you are already writing, and the fragment has no say in the surrounding page. A template can extend exactly one base, but include as many partials as it likes.

templates/partials/_navbar.html:

html
<nav>
  <a href="{{ url_for('home') }}">Home</a>
  <a href="{{ url_for('about') }}">About</a>
</nav>
html
{% include "partials/_navbar.html" %}
  • inside base.html to share nav/footer
  • in pages to share repeated UI patterns

Many teams prefix partials with _ (like _navbar.html) to signal “not a full page”.

Jinja doesn’t require it, but it helps humans.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading