Key Concepts › Templates Library
layout.jinja
The frame every page is rendered inside. It is the one template a theme cannot leave out.
Required
layout.jinja must place both platform tags, outside any comment, or the theme is refused
when it loads:
| Tag | Where |
|---|---|
{% wajha_head %} | Inside <head> |
{% wajha_body %} | Just before </body> |
A complete layout
This is the shape of the built-in theme's layout:
<!doctype html>
<html lang="{{ request.locale }}" dir="{{ request.direction }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}{{ store.name }}{% endblock %}</title>
{% wajha_head %}
<link rel="stylesheet" href="{{ theme.asset_base }}/theme.css">
</head>
<body>
<a class="skip-link" href="#main">{{ t.a11y.skip }}</a>
{% include "partials/header.jinja" %}
<main id="main">
{% block content %}{% endblock %}
</main>
{% include "partials/footer.jinja" %}
{% wajha_body %}
</body>
</html>
What belongs here
- Language and direction on
<html>, fromrequest.localeandrequest.direction. Set them once, here, and every page inherits them. - The title block. Pages override
{% block title %}; the layout's default is the store's name. - Your stylesheet, through
theme.asset_base. A theme that extends another links the parent's first, throughtheme.parent_asset_base, so the pages it inherits stay styled — see Extending another theme. - The skip link, header and footer — anything identical on every page.
What does not
- Canonical and alternate links.
{% wajha_head %}writes them. Writing your own as well puts two canonical URLs on the page, and a search engine ignores both. - Inline
<script>. Pages are served with a policy that refuses inline script; ship JavaScript as a file inassets/.
Data
Every value in How Context Is Built under "What every page has today" is available here, because the layout is rendered as part of every page.