Skip to content
shopdepot.dev

Themes

Templates

JSON templates, alternate templates, section groups and the page types a theme renders.

View as Markdown

A template decides which sections a page type shows. Templates are JSON only, in templates/, one per page type.

Format

{
  "sections": {
    "main": {
      "type": "main-product",
      "settings": { "gallery_layout": "auto", "show_breadcrumbs": true },
      "blocks": {
        "title": { "type": "product-title" },
        "price": { "type": "price", "settings": { "show_lowest_30d": true } },
        "buy": { "type": "buy-buttons" }
      },
      "block_order": ["title", "price", "buy"]
    },
    "reviews": { "type": "product-reviews", "settings": { "limit": 10 } }
  },
  "order": ["main", "reviews"]
}
  • sections - entries keyed by an id you choose, unique in the file. type is the file name of a section.
  • settings - values for the section's schema settings. Missing ones take the schema default.
  • blocks and block_order - the blocks inside a section, the same shape again, nested as deep as the blocks allow.
  • order - the order of sections on the page.
  • "disabled": true on an entry keeps it in the file but does not render it.

The merchant's arrangement from the theme editor is stored with their store and wins over the file. Your file is what a new installation starts with - and what the editor offers to reset to.

Page types

Each storefront page type has a template and receives its own variables: product.json gets a product, category.json a category with its listing, cart.json the visitor's cart. The full list, with addresses and variables, is in Page types.

A store page without a template in your theme falls back to the platform's built-in rendering, so ship every type base ships.

The category page

Besides the name and the listing, a store category carries what the merchant set in Catalog → Categories: the page heading, a description, an image, an icon and a second description. All of them are optional, so test each one for emptiness:

{% set c = category %}
<h1>{{ c.heading }}</h1>
{% if c.description %}<div class="rte">{{ c.description|raw }}</div>{% endif %}

{% if c.image and pagination.page|default(1) == 1 %}
  {{ c.image|image_url(width: 2400)|image_tag(alt: c.image.alt, loading: 'eager', fetchpriority: 'high', sizes: '100vw') }}
{% endif %}

{# the listing #}

{% if c.additionalDescription and pagination.page|default(1) == 1 %}
  <div class="rte">{{ c.additionalDescription|raw }}</div>
{% endif %}
  • heading is the H1 of the category page (the name when the merchant left it empty). Use title in menus, tiles and breadcrumbs.
  • image is a banner or a tile picture. On the category page it is usually above the fold, so it loads eagerly with fetchpriority: 'high'.
  • additionalDescription is longer text for below the products: a buying guide, an FAQ, SEO text. Show it on the first page of the listing only, so the same text is not repeated on ?page=2.
  • icon is a small picture for menus and chips. It can be an SVG (icon.vector), which you can draw as a CSS mask so it takes the text colour. It is decorative, so give it an empty alt.

Both descriptions are HTML cleaned by the platform, so print them with |raw. The same image and icon come in children.json for menus loaded on demand. Every field is in the category reference.

Alternate templates

Some pages can use a different template than the default one of their type. The alternate goes after a dot:

File Used for
product.<suffix>.json Offers whose template the merchant set to <suffix> on the offer page. Every product.*.json in the published theme appears in that list.
category.<suffix>.json Store categories whose template the merchant set to <suffix> in Catalog → Categories. The choice belongs to one category: its subcategories stay on category.json until they pick their own.
page.<last path segment>.json The page at that address - page.contact-us.json renders /contact-us/ and /help/contact-us/.
terms.<feature code>.json, term.<feature code>.json The index and value pages of one feature - terms.authors.json.

A suffix that does not exist in the theme renders the default template, so removing an alternate never breaks a page.

Section groups

sections/header-group.json and sections/footer-group.json hold the sections around every page, in the same format with a type:

{
  "type": "header",
  "sections": {
    "announcement": { "type": "announcement-bar", "settings": { "text": "Free delivery over 199 PLN" } },
    "header": { "type": "header", "settings": { "menu": "main-menu" } }
  },
  "order": ["announcement", "header"]
}

The layout renders a group with {{ sections('header-group') }}. Section groups sit directly in sections/, not in a subfolder, and their names end with -group.json.

Limits

Keep a template to a reasonable number of sections - each one is rendered and cached separately, and every extra band is weight on the page. The theme store review looks at the default templates of your theme.