Menus and widgets
Menu placements, link types, mega-menu panels, lazy menu levels and reusable widgets.
Menus and widgets are content the merchant manages outside the theme editor, in the store's admin. Your theme declares where they go and what they start with.
Menu placements
Declare placements in theme.json. Installing or publishing the theme creates a store menu for each placement that has none and assigns it; a merchant's own assignment always wins.
A section reads a menu with a link_list setting:
{ "type": "link_list", "id": "menu", "default": "main-menu", "label": "t:sections.header.menu" }
The value is a menu handle or a placement handle, and the template gets a menu object:
{% set menu = section.settings.menu %}
{% if menu %}
<nav aria-label="{{ menu.title }}">
<ul>
{% for link in menu.links %}
<li>
<a href="{{ link.url }}"{% if link.active %} aria-current="page"{% endif %}>{{ link.title }}</a>
{% if link.links %}
<ul>{% for child in link.links %}<li><a href="{{ child.url }}">{{ child.title }}</a></li>{% endfor %}</ul>
{% endif %}
</li>
{% endfor %}
</ul>
</nav>
{% endif %}
Link types
type |
Points at | target |
|---|---|---|
home |
The home page | - |
page |
A store page | page |
post |
A blog post | post |
blog |
The blog | - |
product |
An offer | offer |
category |
A store category, or all for every top-level category |
category or all |
url |
Any address: a store path, http(s), mailto:, tel:, # |
the address |
pages |
(default contents only) the store's top-level pages, up to limit |
- |
Links to drafts and deleted items are hidden automatically.
Mega-menu panels
A top-level link can open a panel. The merchant configures it per link; your template reads it from the link:
link.hasPanel,link.panel- the mode:links,html_linksorhtml,link.linksandlink.levels- the columns (subcategories are filled in automatically for a category link withsource: categories),link.panelHtml- the merchant's own HTML, sanitised,link.featured- an offer pinned to the panel.
Menu levels on demand
A store can have hundreds of categories. Do not render them all into every page: render the levels the panel shows and load deeper ones when the visitor gets there. A category link has link.hasChildren and link.childrenUrl:
GET /categories/<handle>/children.json?sort=popular&limit=12&products=3
{
"category": { "id": "…", "handle": "face", "title": "Face", "url": "/categories/face/" },
"total": 74,
"children": [
{ "id": "…", "handle": "serums", "title": "Serums", "url": "/categories/serums/", "count": 18, "has_children": true, "children_url": "/categories/serums/children.json", "icon": "https://cdn.example/m/…/icon.svg", "icon_vector": true, "image": "https://cdn.example/m/…/serums_480.webp" }
],
"products": [
{ "id": "…", "title": "…", "url": "…", "image": "…", "price": 12900, "price_formatted": "129,00 zł", "price_varies": false, "available": true }
]
}
icon is the category icon set in the admin (null without one) and icon_vector says it is an SVG - in the page the same icon is category.icon (see category). image is the category image as a 480 px thumbnail (null without one), for category tiles in a mega menu - in the page it is category.image. all instead of a handle returns the top-level categories. Parameters: sort=popular (units sold in 90 days), limit (0 for all - total always counts all), products (bestsellers of the category, up to 6), empty=1 (include categories without offers). The answer is the same for every visitor and cached for five minutes in the browser.
Widgets
A widget is a configured, named instance of one of your sections that the merchant fills once and shows in many places - for example the same testimonials on the home page and on every offer page. Change it once, it changes everywhere.
Declare widget placements in theme.json. A section points at a widget with a widget setting and renders it:
{ "type": "widget", "id": "testimonials", "default": "testimonials", "label": "t:sections.slot.widget" }
{{ render_widget(section.settings.testimonials) }}
render_widget('testimonials') also works with a handle or placement name. A placement the merchant has not filled renders nothing. base ships widget-slot, a section that only renders a chosen widget - reuse it.
If the merchant switches to a theme without that section type, the widget renders nothing and keeps its content for when the type is back.