Skip to main content

Nunjucks Theme API

Version: 1.0.0 (MARKT_NUNJUCKS_API_VERSION) Framework-agnostic Nunjucks engine for MARKT storefronts. Themes use standard Nunjucks (extends, include, macro, for, if) plus the stable context below. For product grids and tags, also read Shortcodes & Tags and Build a Custom Theme. Before shipping a live Nunjucks theme, read Nunjucks Theme Pitfalls (autoescape, Alpine x-data, cartPage, lean cart API, visibility). Legal pages: Policy & Legal Pagesstore.policies.* and files privacy-policy.njk / terms.njk / refund-policy.njk.

Architecture


Lifecycle


Context objects (stable v1)

Types: lib/builder/nunjucks/api/types.ts

MarktProduct (summary)

Typical fields: id, slug, name, description, image, minPrice / maxPrice (not a top-level price), visibility, stock (-1 = unlimited), variants, groupId.

Product groups

  • Prefer catalogItems / standaloneProducts for homepage grids — never list every products entry as a card when groups exist.
  • Group members: helpers.components.products.getItemsByIds(products, group.productIds).

On-hold (visibility)

Checkout / embed APIs also reject on-hold — UI disable is still required.

Filters


Tags


Globals


Minimal theme layout


Cart

MarktCartItem shape (camelCase):
Themes with components/cart-page.njk get markt-cart-client injected for quantity/remove/checkout sync.

settings.json

Missing template entries are auto-discovered from templates/*.njk.

Extensions (optional)

Built-in markt.sellauth activates for legacy {% render_component %}, {% render_snippet %}, apiInternalUrl, or schema.json. Native themes use Join Markt tag names only.

Stability

  • Minor/patch: additive fields/filters/extensions
  • Major: removing/renaming core context keys, filters, or globals

Validation