Tutorial: build a digital products store theme
Tutorial: build a Sneferu theme for a digital products store, from a design mockup to a live Hekana store, with the Bento example theme.
On this page
This tutorial builds Bento, a home page for a shop that sells printables, templates and e-books as digital files, from a design mockup to a live store. It uses only the CLI and the parts of Sneferu described in the earlier chapters. The finished theme is live at demo-bento.hekana.com (Arabic) and demo-bento.hekana.com/en (English).
This page shows the key part of each file. Full theme on GitHub:
examples/themes/bento,
with its own README.md. Every excerpt links to its whole file. To run it
yourself:
git clone --depth 1 https://github.com/hekanahq/sneferu
cd sneferu/examples/themes/bento
npx sneferu devThe mockup was generated as a design brief. Its Arabic is placeholder text, and its lavender and pink tiles become sky blue and peach.
The home page template lists the sections and seeds their repeated items (tabs, shelves, list items, questions) as blocks, so a fresh install shows the whole page. The excerpt shows the first section and its first block.
<hk-sections />
<hk-schema>
{
"sections": [
{
"type": "tabs",
"blocks": [
{
"type": "tab",
"settings": {
"label": {
"ar": "الكل",
"en": "All"
},
"link": "#shop",
"current": true
}
},


Two more themes were built the same way and follow the same steps. Each home page is a template listing its sections, like Bento's above:
| Theme | What it shows | Live | Files |
|---|---|---|---|
| Creator | editorial covers in a scroll-snap row, a checklist, an author strip | demo-creator.hekana.com | examples/themes/creator |
| License | dark, plan cards built from products, app cards, a FAQ accordion | demo-license.hekana.com | examples/themes/license |
<hk-sections />
<hk-schema>
{
"sections": [
{
"type": "covers"
},
{
"type": "what-you-get",
"blocks": [
{
"type": "get-item",
"settings": {
"term": {
"ar": "الملفات",
"en": "Files"
},
"text": {
"ar": "رابط التحميل بيوصلك على الإيميل بعد الدفع أونلاين",
"en": "Your download link is emailed after online payment"
}
}
},<hk-sections />
<hk-schema>
{
"sections": [
{
"type": "plans-hero"
},
{
"type": "features",
"blocks": [
{
"type": "feature",
"settings": {
"text": {
"ar": "مفتاح الترخيص على الإيميل بعد الدفع",
"en": "Licence key by email after payment"
}
}
},

Each example folder has a README.md that walks through its own files the
same way this page walks through Bento.
1. Plan the data
Before writing a template, decide what the page reads. Bento shows two
categories of products. Each shelf has a collection setting, so the merchant
picks the category in the editor; the theme's defaults are these handles:
| Handle | Shelf |
|---|---|
printables | the first shelf |
templates | the second shelf |
A store that has categories with these handles shows the page filled in on
install; any other store picks its own. Everything else on the page is a
product field (title, url, price, image), a setting, or a word from the
locale files.
2. Create the theme and the sample data
npx sneferu init bento
cd bentoDelete the starter's sections/hero.snf, sections/featured.snf and
blocks/chip.snf; the theme writes its own.
The dev preview's built-in sample products are game cards, and its only
collection is featured. To preview with this store's own products, write
.sneferu-dev/data.json. It can be split by locale, one block per language:
"en": {
"store": {
"name": "Daftar"
},
"collections": {
"printables": {
"title": "Printables",
"products": [
{
"title": "Sunny colouring book",
"url": "/en/products/sunny-colouring-book",
"price": 6900,
"compare_at": null,
"image": {That is the start of the "en" block; an "ar" block before it has the same
products with Arabic titles, so ?locale=ar previews in Arabic. The folder starts with a dot, so it is never
part of the theme and never pushed. (Getting started
has the details; it needs the CLI from Sneferu main after #16.)
3. Tokens
"defaultLocale": "ar",
"locales": ["ar", "en"],
"settings": {},
"tokens": {
"colors": {
"primary": "#1F2433",
"secondary": "#74B8AE",
"accent": "#E9946C",
"background": "#FFFFFF",
"text": "#1F2433",
"muted": "#5F6474",
"sage": "#CFE3D7",
"peach": "#F7C9AF",
"warm": "#FCF1EA",
"sky": "#E8F1FA",
"teal": "#74B8AE",
"line": "#E8E6E1"
},
"layout": { "contentWidth": "1040px" },
"fonts": {
"heading": "Baloo Bhaijaan 2",
"body": "Baloo Bhaijaan 2"
}defaultLocale: "ar"makes/Arabic, right to left;/enis English.- Every colour the page uses is a token. The extra keys (
sage,peach,warm,sky,teal,line) become--hk-color-sageand so on. - No purple, lavender or pink anywhere: the mockup's lavender panel is
skyand its pink tile ispeach.
The font is a token: "fonts": { "heading": "Baloo Bhaijaan 2", "body": "Baloo Bhaijaan 2" }.
Baloo Bhaijaan 2 is in the font catalogue and has Arabic glyphs; Hekana serves
the files and sets the family on the theme root, so the stylesheet has no
@font-face and no font-family:
.bt {
background: var(--hk-color-background);
color: var(--hk-color-text);
line-height: 1.5;
min-height: 100vh;
}4. Layout
<div class="bt">
<hk-section-group name="header" />
<main><hk-slot name="content" /></main>
<hk-section-group name="footer" />
</div>The header and the footer are section groups:
groups/header.json and groups/footer.json start them with the sections
bento-header and bento-footer, and the merchant edits them once for the
whole store. The end of the header row, with the cart, the search and the phone
menu:
<div class="bt-end">
<a
class="bt-icon bt-hide-phone"
href="{{ url('/cart') }}"
data-hk-open="cart-drawer"
aria-label="{{ t('cart') }}"
><hk-icon name="shopping-bag" /><hk-cart-count /></a>
<a class="bt-icon bt-hide-phone" href="{{ url('/search') }}" aria-label="{{ t('search') }}"><hk-icon
name="search"
/></a>
<a class="bt-pill" href="{{ url('/products') }}">{{ t('all_products') }}</a>
<details class="bt-menu">
<summary class="bt-icon" aria-label="{{ t('menu') }}"><hk-icon name="menu" size="22" /></summary>
<div class="bt-menu-panel">
{% for item in menu(section.settings.menu).items %}<a
href="{{ item.url }}"
aria-current="{{ item.active }}"
>{{ item.title }}</a>{% endfor %}<a href="{{ url('/search') }}">{{ t('search') }}</a>
<a href="{{ url('/cart') }}" data-hk-open="cart-drawer">{{ t('cart') }}</a>
<a href="{{ url('/wishlist') }}">{{ t('wishlist') }}</a>
<hk-locale-switch />
</div>
</details>- The page goes where
<hk-slot name="content" />is. - Cart links carry
data-hk-open="cart-drawer": with the controllers running they open<hk-cart-drawer>, without them they go to the cart page.<hk-cart-count />shows the number of items. - All words are
t('…'). Links go throughurl():url('/cart')is/carton an Arabic page and/en/carton an English one. The language switch is<hk-locale-switch />: it links to the same page in the other language. - The phone menu is
<details>/<summary>: it opens without script. - The menu panel starts with the store's own menu,
menu(section.settings.menu)(themainmenu unless the merchant picks another); see Menus. - Icons are
<hk-icon name="shopping-bag" />from the bundled set. The filled avatar has no match in the set, so it stays an inline SVG insnippets/glyph.snf.
5. The template
The template is the one shown at the top of this page: three sections, in order, with their default blocks: four tabs and two shelves. A merchant can reorder the sections, edit or add blocks, or add more sections in the builder.
6. The shelves
This is the heart of the page: a section whose blocks are shelves. Each shelf block has its own collection, words and colours.
<section class="bt-bento" id="shop">
<div class="bt-wrap bt-bento-grid">
{% for block in section.blocks %}
<hk-block of="{{ block }}" />
{% endfor %}
</div>
</section>
<hk-schema>
{
"name": "Bento shelves",
"version": 1,
"settings": {},
"blocks": {
"allowed": ["shelf"],
"max": 4
}
}
</hk-schema><div class="bt-shelf" id="{{ block.settings.list }}">
<a class="bt-head" data-tone="{{ block.settings.head }}" href="{{ url(block.settings.link) }}">
<h2>{{ block.settings.title }}</h2>
<span class="bt-thumbs" aria-hidden="true">
{% for p in collection(block.settings.list).products limit: 5 %}
{% if p.image %}<img src="{{ p.image.url }}" alt="" width="28" height="28" loading="lazy" />{% endif %}
{% endfor %}
</span>
</a>
<div class="bt-panel" data-tone="{{ block.settings.panel }}">
<div class="bt-chips">
<span class="bt-chip bt-chip-on">{{ t('chip_instant') }}</span>
<span class="bt-chip">{{ t('chip_pdf') }}</span>
<span class="bt-chip">{{ block.settings.note }}</span>
</div>
{% if collection(block.settings.list).products %}
<div class="bt-covers">
{% for p in collection(block.settings.list).products limit: block.settings.count %}
<div class="bt-cover">
<hk-product-card product="{{ p }}" class="bt-card">
<hk-part name="badge">{% if forloop.first %}<span class="bt-new">{{ t('badge_new') }}</span>{% endif %}</hk-part>
</hk-product-card>
</div>
{% endfor %}
</div>
How it works
collection(block.settings.list)reads the collection the merchant picked for this shelf (printablesandtemplatesin the template). With nothing picked it is empty, and nothing is fetched.data-tone="{{ block.settings.head }}"writespeach,sage,skyorwarm. A template cannot build astyle="…"from data (SN2009), so the colour comes from one CSS rule per tone:[data-tone="peach"] { background: var(--hk-color-peach); }.{% for p in collection(block.settings.list).products limit: 5 %}draws the round thumbnails in the header tile; the covers uselimit: block.settings.count, arangesetting.{% if collection(block.settings.list).products %}is false for an empty collection: the panel then shows one line of text instead of an empty grid.<hk-product-card product="{{ p }}" class="bt-card">renders the cover, the title and the price as one link. The "New" badge is itsbadgepart (<hk-part name="badge">), so it sits inside the link, before the image, and only onforloop.first.- The shelf's
idis the collection handle, so the tab links#printablesand#templatesscroll to the shelves.
The grid and the covers, from the stylesheet:
/* Bento shelves: a header tile over a panel, two side by side */
.bt-bento { padding-block: 0 24px; }
.bt-bento-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bt-shelf { display: flex; flex-direction: column; gap: 10px; }
.bt-head {
display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 18px 24px 16px;
border-radius: 28px; min-height: 84px;
}
.bt-head h2 { margin: 0; font-size: 21px; font-weight: 600; line-height: 1.3; }
.bt-thumbs { display: flex; }
.bt-thumbs img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; border: 2px solid #FFFFFF; margin-inline-end: -6px; }
.bt-panel { position: relative; padding: 18px 22px 60px; border-radius: 28px; }
.bt-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.bt-chip { font-size: 12.5px; padding: 3px 12px; border-radius: 999px; color: var(--hk-color-muted); }
.bt-chip-on { background: var(--hk-color-peach); color: var(--hk-color-text); }
.bt-covers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.bt-cover { position: relative; }
.bt-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.bt-card img { width: 100%; aspect-ratio: 5 / 6; object-fit: cover; border-radius: 16px; display: block; margin-bottom: 6px; }
.bt-card .sn-title { font-size: 13px; font-weight: 600; line-height: 1.35; }7. The band
<section class="bt-band-wrap">
<div class="bt-wrap">
<div class="bt-band">
<div>
<h2>{{ section.settings.heading }}</h2>
<p>{{ section.settings.text }}</p>
</div>
<hk-button label="{{ section.settings.button }}" href="{{ section.settings.link }}" class="bt-band-button" />
</div>
</div>
</section> "heading": {
"type": "text",
"label": "Heading",
"localized": true,
"default": {
"ar": "اطبع النهارده",
"en": "Print it today"
},
"maxLength": 80
},
The text settings are "localized": true, with a default in each language,
like the heading above. The editor shows one field per
language, and {{ section.settings.heading }} prints the one for the page.
The button link is a link setting; hk-button keeps it in the page's
language.
hk-button renders <a class="sn-btn sn-btn-solid"> with no visual style of
its own; the theme styles it through the class it passes (bt-band-button).
8. Phones
One media query at 639 px, the width the mobile- props use, stacks the
shelves and rearranges the header:
@media (max-width: 639px) {
.bt-wrap { padding-inline: 12px; }
.bt-hide-phone { display: none; }
.bt-menu { display: block; }
.bt-header-row { justify-content: flex-start; gap: 6px; }
.bt-start, .bt-end { display: contents; }
.bt-menu { order: -1; }
.bt-logo { margin: 0; }
.bt-pill { margin-inline: auto 0; min-height: 44px; padding-inline: 18px; font-size: 13px; }
.bt-user { display: none; }
.bt-tabs { padding-block: 4px 10px; }
.bt-tabs-row { justify-content: flex-start; gap: 20px; }
.bt-tabs-row a { font-size: 15px; }
.bt-bento-grid { grid-template-columns: 1fr; gap: 10px; }
.bt-head { border-radius: 24px; padding: 14px 20px; min-height: 76px; }
.bt-head h2 { font-size: 19px; }
.bt-panel { padding: 14px 12px 56px; border-radius: 24px; }
.bt-covers { gap: 8px; }
.bt-card .sn-title { font-size: 12px; }
.bt-band { border-radius: 28px; padding: 22px; justify-content: center; text-align: center; }
.bt-band-button.sn-btn { width: 100%; }
}9. Check, preview and push
npx sneferu formatindents every file.npx sneferu validateprints✔ theme [email protected] is valid.npx sneferu devand openhttp://127.0.0.1:4100, then?locale=en. Narrow the window below 640 px.- Change
idintheme.jsonto a slug of your own, thennpx sneferu push . --package <your-slug> --dev-store. - On a real store, create the two categories with the handles from step 1, or pick other categories for the shelves in the editor.
Every page of the store goes through the theme: Bento 2.0 has its own product, collection, search, cart, content page and 404 templates, and a shared header, footer and announcement bar the merchant edits once (see Page types and Section groups).
What to know before you build your own
The three digital themes were first built on Sneferu 0.2; version 2.0 (Sneferu 0.6) made them complete stores. What is still missing:
| Limit | What the three themes do |
|---|---|
| no carousel and no JavaScript | menus and questions use <details>; Creator's covers row is scroll-snap with anchor dots |
images in assets/ are served, but these themes bundle none | art comes from products, inline SVG, or an image setting with an https:// default |
url() cannot link to the other language | <hk-locale-switch /> links to the same page in the other language (since Sneferu 0.4) |
money prints two decimals unless the theme sets "money": { "format": "whole" } | these themes keep two decimals (EGP 69.00) |
