Overview

Templates define how your content is rendered into HTML. Hwaro uses Crinja, a Jinja2-compatible template engine.

Template Directory

  templates/
├── base.html           # Base layout
├── page.html           # Regular pages
├── section.html        # Section index pages
├── index.html          # Homepage (optional)
├── taxonomy.html       # Taxonomy listing
├── taxonomy_term.html  # Taxonomy term page
├── 404.html            # Error page
└── shortcodes/         # Shortcode templates

Template Selection

Content Template
`content/index.md` `index.html` or `page.html`
`content/about.md` `page.html`
`content/blog/_index.md` `section.html`
`content/blog/post.md` `page.html`
Taxonomy index `taxonomy.html`
Taxonomy term `taxonomy_term.html`

Basic Syntax

Variables

  {{ page_title }}
{{ site_title }}
{{ content }}

Conditionals

  {% if page_description %}
<meta name="description" content="{{ page_description }}">
{% endif %}

Template Inheritance

Base template:

  <!DOCTYPE html>
<html>
<head>
  <title>{% block title %}{{ site_title }}{% endblock %}</title>
</head>
<body>
  {% block content %}{% endblock %}
</body>
</html>

Child template:

  {% extends "base.html" %}

{% block title %}{{ page_title }} - {{ site_title }}{% endblock %}

{% block content %}
<article>{{ content }}</article>
{% endblock %}

Includes

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

In This Section

In This Section