novinzodevelopers
Storefront & themes

Liquid themes

Create theme files, use the public render context, and call plugin data and blocks from Liquid.

The storefront renders each page from the store theme. Themes use Liquid templates, static assets, and browser JavaScript.

You can author these files in your own project without private packages. Novinzo renders its additional tags and objects in the hosted storefront.

Deploying a theme

A store owner links a GitHub repository and branch in Settings → Theme, usually one created from the public emergente-labs/novinzo-theme-starter template. The public emergente-labs/novinzo-theme-deploy@v1 action then deploys each push to POST /themes/deploy, authenticated with GitHub OIDC.

Theme structure

A theme version identifies one set of components and assets. Each successful deploy publishes the next version, numbered 1.0.1, 1.0.2 and so on; you never set it.

ComponentDirectoryPurpose
Layoutlayouts/The page shell, selected with {% layout 'name' %}.
Templatetemplates/A page type, such as the home or product page.
Sectionsections/A reusable region, included with {% section 'name' %}.
Snippetsnippets/A helper, included with {% render 'name' %}.

A theme that ships every file itself uses this structure. A theme that extends the starter ships only the files it changes:

my-theme/
  theme.json
  layouts/default.liquid
  templates/index.liquid
  templates/product.liquid
  templates/checkout.liquid
  templates/checkout-cancel.liquid
  templates/login.liquid
  templates/orders.liquid
  templates/order-detail.liquid
  templates/policy.liquid
  templates/404.liquid
  templates/error.liquid
  sections/header.liquid
  sections/footer.liquid
  snippets/product-card.liquid
  assets/theme.css

A deploy reads name, 1 to 128 characters, and the optional routes, extends and settings from theme.json. Other fields are the theme's own.

A local directory alone does not publish or install the theme. The deploy action sends theme.json, the Liquid in the component directories, and web-type files under assets/.

Assets use /theme/assets/* on the store domain. The asset_url filter produces their URLs, adding ?v=<hash> for a published file so browsers can keep it for good.

A published theme version is never changed. To change the theme, deploy again.

A layout outputs the page content. The storefront injects the hosted component scripts right after the layout's opening <head> tag, so a layout needs no script hook:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="{{ 'theme.css' | asset_url }}">
</head>
<body>
  {% section 'header' %}
  <main>{{ content_for_layout }}</main>
  {% section 'footer' %}
  <nz-cart-drawer store-id="{{ store.id }}"></nz-cart-drawer>
</body>
</html>

Extending the starter

A theme can build on Novinzo's starter theme instead of copying all of it. Name the starter release the theme was made from in theme.json:

{
  "name": "My theme",
  "extends": "starter@1.0.0"
}

The storefront then serves every layout, template, section, snippet and asset the theme does not have from the starter. Delete the starter's files you have not changed, and the pages they render follow the starter as Novinzo updates it, including fixes and the move away from deprecated features. The theme's own file always wins over the starter's file of the same path.

The version names the release the theme's own copies of starter files were taken from, so it can be no newer than the release Novinzo serves. The storefront serves the inherited files from the starter release Novinzo serves now, which stays within the theme's major version: starter@1.0.0 gets every 1.x release Novinzo serves, and Novinzo serves no 2.0.0, which may change what templates rely on, while a live theme extends 1.x. To take a newer release into the copies the theme keeps, see Taking in starter releases.

The theme's stylesheet is built from the starter's Liquid as Novinzo serves it at build time. When a later starter release uses a class no page used before, an inherited page gets that class's style once the theme deploys again; the starter-updates pull request is such a deploy.

A theme that extends the starter must not name a file as one of the starter's of another type, such as snippets/header.liquid beside the starter's sections/header.liquid. A component is looked up by its name alone, so it would replace the starter's on every page.

Inherited pages render with the theme's own stylesheet. The theme CLI and the deploy action write the starter's Liquid to .novinzo/base/ before running the build, and the starter's Tailwind input names it as a source, so the stylesheet keeps the classes those pages use. They write the starter's theme.json settings there too, as .novinzo/base/theme.json.

Subscription pages

Two more templates render the signed-in shopper's subscriptions, and a theme may leave them out:

TemplatePageRender context
templates/subscriptions.liquid/subscriptionsstore, cart and settings.
templates/subscription-detail.liquid/subscriptions/<subscriptionId>Also subscription.subscriptionId.

A theme without one answers the store's 404 page on its path, so a theme deployed before these pages existed keeps deploying. A theme that extends the starter gets both from it. The starter renders them with the nz-subscriptions and nz-subscription-detail elements. Its subscription detail page:

{% layout 'novinzo' %}

<nz-subscription-detail
  subscription-id="{{ subscription.subscriptionId }}"
  store-name="{{ store.name }}"
  store-logo-url="{% if store.logoImageUrl %}{{ store.logoImageUrl | image_url: width: 64 }}{% endif %}"
  data-island="nz-subscription-detail"
  data-hydrate="eager"
></nz-subscription-detail>

Adding pages

The ten required templates render the storefront's own pages. To add pages of your own, such as an About or FAQ page, declare them under routes in theme.json. Each route names a template in templates/:

{
  "name": "My theme",
  "routes": [
    { "path": "/about", "template": "about", "title": "About us", "description": "Who we are." },
    { "path": "/help/shipping", "template": "shipping" }
  ]
}
FieldRule
pathLowercase letters and digits joined by single hyphens, in one or more / segments, with no trailing slash. At most 128 characters.
templateA template in templates/, without .liquid. It cannot be a template of the storefront's own pages, which need their page's data: one of the ten required templates, subscriptions or subscription-detail.
titleOptional, at most 100 characters. Without it, the page uses the store's SEO title, or the store name.
descriptionOptional, at most 255 characters. Without it, the page uses the store's SEO description, or the store name.

A theme declares at most 50 routes, and each path once. The storefront serves its own pages under these first path segments, so a route cannot start with them: __plugin-preview, __theme-preview, _internal, account, api, cart, categories, checkout, components, health, lib, login, orders, plugins, privacy, products, r, refund, search, subscriptions, terms and theme. The deploy refuses a theme with a route that breaks a rule.

The storefront matches a route path the way it matches its own: /About/ serves /about. A path that no route declares gets the store's 404 page.

Theme settings

A theme can let the store's owner change parts of it without touching its code: a colour, a heading, whether a section shows. Declare each one under settings in theme.json:

{
  "name": "My theme",
  "settings": [
    { "id": "accent_color", "type": "color", "label": "Accent colour", "default": "#d4f264" },
    {
      "id": "hero_heading",
      "type": "text",
      "label": "Heading",
      "group": "Home page",
      "default": ""
    },
    {
      "id": "show_category_filter",
      "type": "boolean",
      "label": "Show the category filter",
      "group": "Home page",
      "default": true
    },
    {
      "id": "card_style",
      "type": "select",
      "label": "Product cards",
      "default": "filled",
      "options": [
        { "value": "filled", "label": "Filled" },
        { "value": "outlined", "label": "Outlined" }
      ]
    },
    { "id": "hero_image", "type": "image", "label": "Hero image", "group": "Home page" }
  ]
}
FieldRule
idWhat templates read after settings.: a lowercase letter, then lowercase letters, digits and underscores. At most 64 characters.
typetext, textarea, color, boolean, select or image.
labelWhat the owner reads beside the field, 1 to 64 characters.
groupOptional. The heading the field is shown under, 1 to 64 characters. Settings without one come first.
defaultThe value a store has until its owner changes it. Required for every type but image, which has none.
optionsFor a select only: 1 to 50 choices, each a value and a label. The default is the value of one of them.
TypeDefaultWhat a template reads
textA string of up to 500 charactersThe string.
textareaA string of up to 5,000 charactersThe string.
colorA hex colour, #rgb or #rrggbbThe hex colour.
booleantrue or falsetrue or false.
selectOne option's valueThe chosen option's value.
imageNoneThe image's URL, or nil until the owner uploads one.

The owner edits them in the dashboard under Settings → Theme → Theme settings. Every page receives them as settings, and every setting always has a value there, the owner's or its default:

<html lang="en" style="--color-price: {{ settings.accent_color }}">

<h1>{{ settings.hero_heading | default: store.headline }}</h1>

{% if settings.show_category_filter %}
  {% plugin_block "categories/category-dropdown@1" %}
{% endif %}

{% if settings.hero_image %}
  <img src="{{ settings.hero_image }}" alt="">
{% endif %}

A saved value reaches the storefront like any other change to the store, within a few minutes at most. Values belong to the store and the theme, and are read against the settings of the version that is live:

  • A setting a new version adds starts at its default.
  • A setting a new version drops is ignored, so removing one never breaks a store.
  • A saved value the setting no longer takes, such as text where it now wants a colour or a select value that is no longer an option, reads as the default.

A theme that extends the starter has the starter's settings too, as the pages it inherits read them. They come first, followed by the theme's own; declare a setting with the same id to replace the starter's. The starter declares accent_color, hero_heading, hero_text, show_customer_count and show_category_filter.

A theme declares at most 100 settings, and each id once. The deploy refuses a theme whose settings break a rule, and warns about a template that reads a settings.<id> neither the theme nor the starter declares, since that renders empty.

Search engines

The storefront tells search engines about a store without help from the theme. Every URL it gives them uses the store's origin: its verified custom domain, or its platform subdomain when it has none.

WhatContents
/sitemap.xmlThe home page, each published policy, every product (up to 10,000) and every theme route.
/robots.txtAllows every page, keeps crawlers off /api/, /plugins/ and /r/ (affiliate links), and names the sitemap.
Link headerrel="canonical" on the home page (with its category), product pages, policy pages and theme routes, so each is indexed once whatever host or spelling reached it.
X-Robots-Tagnoindex on the checkout, login and order pages, which belong to one buyer.
discord-embed.jsonThe Discord embed of the home page (/discord-embed.json) and of each product page (/products/<slug>/discord-embed.json).

The sitemap, robots.txt and the Discord embeds are cached until the store's products, policies or theme change.

The page's <title> and description are the theme's to write. On a theme route, write them from page.title and page.description in the layout's <head>.

The storefront writes the rest of what link previews and search engines read. Put two tags in the layout:

<head>
  <title>{{ product.seo.title | default: product.name | default: page.title | default: store.name }}</title>
  {% seo_head %}
</head>
<body>
  {{ content_for_layout }}
  {% seo_body %}
</body>

{% seo_head %} writes the canonical link, the Open Graph and Twitter card tags, and on the home and product pages the link to the page's Discord embed. The tags use the product on a product page, the route's title and description on a theme route, and the store's SEO fields on other pages.

{% seo_body %} writes schema.org JSON-LD: a Product with its price on a product page, and the store's WebSite and Organization on the home page. Other pages get nothing. Put it at the end of <body>, where it does not delay the page.

Render context

Render context contains the data available to a template. Every page receives store, cart and the theme's settings.

The home page also receives products, categoryFilter and catalogUnavailable. catalogUnavailable is true when the product list could not be read: products is then empty, and the theme should show an error rather than an empty catalog. A product page receives product, including its images, variants, and SEO fields.

A policy page receives policy.title and policy.body. An error page receives error.

A page added through routes receives page.path, page.title and page.description:

{% layout 'default' %}

<h1>{{ page.title }}</h1>
<p>{{ page.description }}</p>

ThemePreviewGetContext describes the exact home and product context schemas. Its pageId values are index and product.

ThemePreviewGetFiles describes the theme files keyed by path. Both operations require an authorized seller session, not a plugin credential.

The schema pages remain useful without access to those operations. To see a theme render with a store's real data, preview it with the theme CLI instead of sharing seller credentials.

{% layout 'default' %}

<h1>{{ store.name }}</h1>
<ul>
  {% for product in products %}
    <li>
      <a href="/products/{{ product.urlSlug }}">{{ product.name }}</a>
      {% if product.lowestVariantPrice %}
        from {{ product.lowestVariantPrice | money }}
      {% endif %}
    </li>
  {% endfor %}
</ul>

Novinzo uses store.name and product.name, not Shopify fields such as shop.name or product.title.

Tags, filters and objects

The platform supports these tags:

comment raw if unless case for break continue assign capture
render include section layout plugin plugin_block seo_head seo_body

The parser also accepts tablerow, cycle, increment, decrement, echo and liquid, but they render nothing. paginate is not accepted.

The platform supports these filters:

Output:   escape xml_escape escape_once raw markdown newline_to_br strip_html
          link_to image_tag default json jsonify inspect to_integer
Strings:  append prepend capitalize upcase downcase strip lstrip rstrip
          strip_newlines squish normalize_whitespace remove remove_first
          remove_last replace replace_first replace_last split truncate
          truncatewords number_of_words handle handleize slugify pluralize
Arrays:   size first last join slice reverse sort sort_natural uniq compact
          concat push unshift pop shift sample map sum where reject where_exp
          reject_exp group_by group_by_exp has has_exp find find_exp find_index
          find_index_exp array_to_sentence_string
Numbers:  plus minus times divided_by modulo abs ceil floor round at_least
          at_most
Money:    money money_with_currency money_minor_units money_amount
Dates:    date date_to_xmlschema date_to_rfc822 date_to_string date_to_long_string
URLs:     asset_url file_url image_url url_encode cgi_escape url_decode uri_escape
Encoding: base64_encode base64_decode sha256 hmac_sha256

Use the page context schema for object fields. Objects include stores, products, variants, images, money, carts, line items, checkouts, orders, customers, payments, and invoices.

Built-in rendering objects are forloop and, in a layout, content_for_layout.

Money uses integer minor units and a currency code. Use money for formatted amounts and money_with_currency to include the ISO code.

A failed section, snippet, or plugin block produces a notice instead of stopping the page. Style the notice through .nz-render-failure.

Calling plugins from Liquid

plugin: fetch data

The plugin tag requests JSON during rendering. It stores the result in a variable and produces no HTML.

{% plugin "categories.all" as categories %}
{% plugin "categories.byProduct", productId: product.id as product_categories %}

{% if categories %}
  {% for category in categories %}{{ category.name }}{% endfor %}
{% endif %}

The quoted route is <plugin code>.<path>. Named plugin: and path: or route: arguments can identify the same route.

Put as <variable> last. Other named arguments form the JSON body, and an object-valued body: argument merges into it.

The storefront sends POST /storefront/<path> with the store header and invocation token. method: "GET" sends a GET with the arguments as its query instead; see Cacheable calls.

The store must have the plugin installed. The plugin takes the store from the trusted header, not a template argument.

The result requires a successful 2xx response and valid JSON. The call has a five-second limit, including response reading, and a 1 MiB response limit.

An unavailable plugin, failed status, invalid JSON, timeout, or oversized response sets the variable to null. The page continues to render.

Use an {% if %} guard before reading the result. See Storefront surfaces for the Worker side of this interface.

plugin_block: render a plugin's snippet

The plugin_block tag renders a versioned Liquid snippet from a plugin:

{% plugin_block "categories/category-dropdown@1", placeholder: "All categories" %}

The reference is <plugin code>/<block id>@<version>, where the version is a positive integer.

The storefront fetches /theme/blocks/<block id>@<version>.liquid. The plugin must serve that file through its private Worker connection.

Named arguments appear inside the snippet as props, such as {{ props.placeholder }}. Variables created inside the snippet do not change the surrounding template.

The storefront fetches and compiles each block at most once per request. The store must have the plugin installed.

An absent plugin or a 4xx block response renders nothing. A 5xx, connection failure, or template failure produces the rendering notice.

On the checkout page (/checkout), only a block that templates/checkout.liquid itself names renders; one that only a layout, section or snippet names renders nothing there. The pay pages of a prepared checkout and of a subscription renewal, and the cancellation page, render no block.

Keep published block versions immutable. Publish name@2.liquid for a change instead of modifying name@1.liquid.

A plugin block must load its own custom-element script from /plugins/<code>/assets/. Automatic script discovery covers the theme templates, not fetched plugin snippets.

Editor tooling

Use your preferred editor with Liquid syntax support. Generic Liquid tooling does not know Novinzo-specific tags or object fields.

Use this guide and the public context schemas as the contract for those additions. No private language server or extension build is required.

A local generic Liquid preview does not exercise Novinzo plugin dispatch or hosted components. npx @emergente-labs/theme-cli dev uploads the theme to a preview of your store on every save, rendered with the store's products, cart and plugins.

Output escaping and render limits

Store, product and policy text comes from the seller. The renderer therefore treats every value as text unless the template marks it as markup.

Escaping by default

Every {{ }} output is HTML-escaped: &, <, >, " and ' become character references. You do not need | escape to make a value safe in text or in a quoted attribute value.

These outputs are already markup and are not escaped again:

OutputWhat it contains
image_tag, link_toElements the filter builds. Their text and attribute parts are escaped.
{% capture %} bodyThe rendered markup, whose own outputs were escaped when it rendered.
escapeA value escaped once, however often escape appears in the chain.
markdownSanitized HTML from Markdown text.
rawThe value as is. Use it only for trusted, already sanitized markup.

link_to links only to relative URLs and to http, https, mailto and tel URLs. Any other scheme, such as javascript:, becomes #.

json writes <, >, &, U+2028 and U+2029 as \u escapes, so {{ value | json | raw }} cannot close a <script> element.

Refused at compile time

Escaping cannot keep a value inert in some positions. A template that places an output there fails to compile, and a theme deploy reports the file, line and column:

PositionExampleWhy
A tag name or an attribute name<{{ tag }}>, <div {{ attrs }}>Whitespace and = in the value would start new attributes.
An unquoted attribute value<div data-x={{ value }}>The same. Quote the value instead.
An event handler attribute<button onclick="go('{{ value }}')">An escaped value is still JavaScript.
A <script> body<script type="application/json">{{ value }}</script>Browsers do not decode entities there. Only {{ value | json | raw }} is accepted.

A template also fails to compile when it contains any of these:

  • An inline <script> with code. Scripts with a src attribute are allowed, and so are data scripts of type application/json, application/ld+json, text/template and text/x-template.
  • An <iframe>, <object> or <embed> element.
  • The text javascript:, data: or vbscript: anywhere in the file, or a CSS expression( call.
  • More than 100,000 characters, more than 10 {% for %} loops, or block tags nested more than 10 deep.

Limits on one render

These limits stop a theme from holding the Worker that serves other stores' requests:

LimitValueWhen it is reached
Render budget200,000 node visits per page render, with each loop iteration's body counted againLiquidRenderBudgetError stops the whole render. Unlike a failed section, it does not produce a notice and carry on.
Expression memory1,000,000 range elements or characters built by string filters, per expressionEvaluating the expression fails with memory alloc limit exceeded.
Component nesting16 nested sections, snippets and plugin blocks, with no component inside itselfThe tag renders the render-failure notice in its place.

The layout, sections, snippets and plugin blocks of one page share a single render budget. The starter's busiest page uses a few thousand visits.

The budget counts work, not time, so a slow plugin or backend call does not use it up. A loop nested over large ranges does.

On this page