البداية
تطوير القوالب
Developing a Wajha theme means combining templates, a settings schema and assets into a storefront a merchant can customise and publish. This page is the loop you will repeat.
The development flow
- Understand the architecture. Read Architecture before writing a template. Most early mistakes are structural, not syntactic.
- Learn the syntax. Jinja Basics covers variables, loops and conditionals. If you are coming from another platform, read What Wajha Does Not Support first.
- Know your data. Each template receives a fixed context. How Context Is Built explains why it is fixed and what you get.
- Declare your settings. Anything a merchant should be able to change goes in the settings schema, never hardcoded.
- Develop locally. The Wajha CLI serves your theme against a development store.
- Validate, publish, test. A theme is compiled and checked before it can go live.
Guidelines
Base layout
Every template extends layout.jinja, and layout.jinja must place two platform tags:
<!doctype html>
<html lang="{{ request.locale }}" dir="{{ request.direction }}">
<head>
<meta charset="utf-8">
<title>{% block title %}{{ store.name }}{% endblock %}</title>
{% wajha_head %}
<link rel="stylesheet" href="{{ theme.asset_base }}/theme.css">
</head>
<body>
{% block content %}{% endblock %}
{% wajha_body %}
</body>
</html>
{% wajha_head %} writes the page's canonical URL, its Arabic and English alternates,
Open Graph tags and, on the homepage, structured data describing the store. On a page that
does not exist it writes noindex instead, so a search engine never indexes an error.
{% wajha_body %} is where the storefront script that cart and checkout need will go; it
writes nothing yet, and is required now so that script can arrive without your theme being
edited.
A layout that does not place both is refused when the theme loads. Without them a store silently loses its search presence and, later, its cart — neither of which shows on the page, which is why it is checked rather than left to a merchant to notice. A tag inside a comment does not count.
You decide where the tags go; the platform decides what they write. Do not write your own canonical or alternate links as well — two canonical URLs on one page cancel each other out.
Default template fallbacks
You do not have to implement every template. A route with no template in your theme falls
back to the platform default, so a theme can ship with only layout.jinja and home.jinja
and still serve a complete store. Implement the pages you have designed; leave the rest.
Theme settings
Never hardcode a value a merchant would reasonably want to change. Colours, headings, the
number of products in a row — those belong in the settings schema, read through settings:
<section style="--accent: {{ settings.accent_color }}">
<h2>{{ settings.featured_heading }}</h2>
</section>
Versioning
A published theme version is immutable. Fixing a bug means publishing the next version, and merchants move when they choose. This is what makes it safe for them to install your theme: nothing you do changes a live store without an explicit update.
Version numbers are semantic. A major version signals that merchant settings may need revisiting; minor and patch versions must not break an existing store.
Error handling
Do not render your own error pages for server failures. When something goes wrong below your template — a timeout, an unavailable service — the platform serves its own page. A theme that catches and hides those makes failures undiagnosable.
A 404.jinja for genuinely missing products or pages is yours to design, and encouraged.
Context size
The data handed to your template is capped — see Limits & Quotas. If a page needs more products than the cap allows, paginate. A page that exceeds the budget fails rather than silently truncating, because a store quietly missing half its catalogue is worse than one that errors loudly.
Testing
A theme is checked in full when it is loaded, and refused whole if anything is wrong, with
the file and line: a template that does not parse, an {% include %} of a file that is not
in the theme, any banned tag or filter, a manifest that is not valid, or ar.json and
en.json holding different keys. Nothing is checked lazily, so nothing half-renders.
A validation report on theme preview URLs — covering settings referenced but not declared, missing platform tags and unescaped links — arrives with theme previews.