Be default Baun uses the Twig template engine to power its themes. Themes are stored in the public/themes folder.

Active Theme

The currently active theme is set in config/app.php:

'theme' => 'baun',

This means Baun will look for template files in the public/themes/baun folder.

Templates

Themes are made up of several template files:

Template Description
page.html The default template for all pages
404.html Shown when no page is found for the current URL
blog.html (optional) Shows a list of posts as the blog index (see blog docs)
post.html (optional) Shows an individual blog post (see blog docs)

You can also create custom templates if you wish.

Template Variables

There are certain variables that Baun passes into your templates and can be used as per Twig’s docs.

Variable Description
{{ content|raw }} Shows the page content that has been converted from Markdown to HTML. You need to use the raw filter as it contains HTML
{{ info }} Contains the attributes from the info section of the page. For example {{ info.title }}{{ info.description }} etc.
{{ base_url }} Base URL of the site
{{ baun_nav() }} Technically this is a function not a variable. See the navigation docs

Layouts

While not required it probably makes sense to make use of Twig’s template inheritance. This means you can create a base template that all other templates can “extend”, saving you the hassle of duplicating lots of HTML. You can create a layout.html template which might look like:

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>My Site</title>
</head>
<body>
    {% block content %}{% endblock %}
</body>
</html>

Then in your other templates you can do the following:

{% extends "layout.html" %}

{% block content %}
    {{ content|raw }}
{% endblock %}

See Twig’s template inheritance docs for more info.