Agent guide
How the Handoff theme is built and the rules to follow when you change or configure it. Read DESIGN.md before any visual work. When the official Shopify documentation contradicts this file, the documentation wins: say so and fix this file.
Priorities
Apply this order to every decision: 1. small screens, 2. content that AI assistants can read and quote (GEO), 3. search engines (SEO), 4. large screens.
Architecture
Online Store 2.0, blocks first.
layout/theme.liquid document shell: head, header group, <main>, footer group
templates/*.json one JSON template per page type, lists sections
sections/*.liquid thin containers, no interface of their own
sections/*-group.json header and footer section groups
blocks/*.liquid theme blocks: all interface lives here
snippets/*.liquid markup without settings, reused by blocks and sections
assets/base.css tokens, reset, base type, layout, shared controls, header, breadcrumb, section containers
assets/product.css first screen of product pages (gallery, buy area), product pages only
assets/collection.css first screen of collection and search pages, those pages only
assets/home.css first screen of the home page (hero, facts)
assets/block-<name>.css styles of one block, loaded where the block is rendered (also snippet-<name>.css, section-<name>.css)
assets/loader.js the only script on first paint, loads components on demand
assets/<name>.js one ES module per interactive component (custom element)
config/ theme settings schema and data
locales/ storefront strings
Rules:
- A section is a container. It renders
{% content_for 'blocks' %}and accepts{ "type": "@theme" }and{ "type": "@app" }. Put markup in a block. - Use a static block (
{% content_for 'block', type: '...', id: '...' %}) for parts that must stay in place, and dynamic blocks for the rest. - A section uses theme blocks or section-defined blocks, never both.
- Shopify wraps a theme block in
<div class="shopify-block">by default. A block whose root element matters to its parent (a list item, a heading, a link, a child of a grid) sets"tag": nullin its schema and prints{{ block.shopify_attributes }}on its own root element. - Child-only blocks are prefixed with an underscore (
_fact,_step,_faq-item): Shopify offers them only inside the parent block that lists them. - Every block starts with a
{% doc %}header, keeps{{ block.shopify_attributes }}on its root element, and has apresetsentry so merchants can add it. - Every high-value block is self-contained: it reads its own settings and the resource it describes, so it can later ship as an app block. It must not depend on hidden global state.
- The theme allows 300 theme blocks at most, including blocks generated by Sidekick. Do not create a block for a one-off need.
- No code from Dawn or Horizon. This theme is original code. Conventions are inspired by Shopify's Skeleton theme (MIT).
- No data that belongs to one store in theme files: no domain, address, delivery time, brand name, or regional wording. Use theme settings, metafields, metaobjects, or locale files.
Patterns already in place
- Variant change. Option values are real links to the variant URL, so the picker works without JavaScript. The
product-infocomponent fetches the section through the Section Rendering API and replaces the content of every element markeddata-variant-region="<name>"with the server-rendered content of the same name. To make a new block follow the variant, put that attribute on its root element. Nothing else is needed. - Checks without JavaScript. Blocks mark content that must be in the raw HTML with
data-check="<name>"(for exampleprice,description,shipping-returns-summary).scripts/check-no-js.mjsreads these markers. - Drawers without JavaScript. The filter panel and the comparison table open with a link to their id and are shown with the CSS
:targetselector. A link back to the results closes them. On large screens they are always visible. - Product list.
snippets/collection-card.liquidis one piece of markup with two layouts: a card on small screens, a table row on large screens and in compare mode. Its spec columns come from the settings of the_collection-resultsblock (vendor, product type, an option, or a product metafield written asnamespace.key). - Heavy media. External videos and 3D models show a preview image and a button. The player is in a
<template>and is inserted on click. For a 3D model, Shopify's viewer controls (model-viewer-ui) and the augmented reality button (shopify-xr) also load on click only. - Early clicks. A control that needs its component carries
data-enhance-click. When a click lands before the module has loaded,assets/loader.jsloads the module, then repeats the click once. Variant links use it, so an early tap updates the page in place instead of reloading it. - Empty blocks take no space. A block that has nothing to show renders nothing, or hides itself with
:not(:has(*)). - Static blocks are prefixed with an underscore (
_product-gallery,_product-sticky-bar,_collection-results,_search-results,_hero-media). - Sections with a heading.
sections/section.liquidcan carry a heading, a rule above it, and a number (01, 02, 03) from a CSS counter. On large screens the heading can sit in a label column on the left.sections/strip.liquidis the same container without padding.sections/hero.liquidputs the static image block next to free theme blocks. - Placeholders. Blocks that need a product, a collection, or an image show Shopify's placeholder drawings and neutral text until the merchant picks one. Default texts are instructions ("Say how many days customers have to return an item"), never invented claims.
GEO blocks
These blocks carry the facts that AI assistants and search engines read and quote. All of them render on the server, mark their root with data-check="<block name>", and render nothing at all when they have no content (so a section that holds only empty blocks hides itself, heading included).
| Block | Reads | Fallback |
|---|---|---|
quick-answer |
text metafield of the page's product, collection, article, or page (custom.quick_answer) |
"Answer" setting |
at-a-glance |
product metafields listed as "Label: namespace.key" lines, plus delivery time and return window from theme settings | none: an empty row is left out |
specs-table |
product metafields listed as "Label: namespace.key" lines, plus SKU, barcode, weight of the selected variant | none |
compatibility-table |
product metafield, list of metaobjects with name, model_codes, status, note (custom.compatibility) |
_compatibility-row child blocks |
faq |
metafield of the page's resource, list of metaobjects with question, answer (custom.faq) |
_faq-item child blocks |
who-its-for |
two product metafields, lists of text (custom.who_its_for, custom.not_for) |
two textarea settings, one point per line |
shipping-returns-summary |
Shipping and Returns theme settings | none |
buying-guide-intro |
collection metafield, rich text or text (custom.buying_guide) |
"Body text" setting |
related-guides |
product metafield, list of articles or pages (custom.related_guides) |
none |
article-products |
article metafield, list of products (custom.related_products) |
product list setting |
Rules for these blocks:
- The metafield is named in a text setting written
namespace.key. Read it once, outside any loop. Never use a setting of typemetaobjectormetaobject_list, and never put a dynamic source to a custom metafield in a shipped JSON template or preset. snippets/metafield-value.liquidturns any metafield into text (measurements with units, lists, category references).snippets/spec-rows.liquidrenders "Label: namespace.key" lines as table rows.snippets/policy-fact.liquidgives the delivery and returns sentences from theme settings: use it wherever those facts appear, so the page never says two different things.- A compatibility that is not verified is
ask, neverfits. Each state shows an icon and a word. - When you configure a store, fill metafields from the product's own data and the store's policies. Leave out what you cannot verify.
Naming
- Files: kebab-case (
quick-answer.liquid). Main sections:main-<page>.liquid. - CSS: BEM-like, prefixed by the name of the block, snippet, or section that uses it (
.quick-answer__question). A class is styled in that file's own CSS file only. Shared classes live inassets/base.css. - Setting ids: explicit snake_case with the unit when there is one (
shipping_handling_days_max, nevers1). Addinfoto every setting that is not obvious: unit, format, example. - Setting labels: American English, sentence case, no ampersand, declarative. Use Shopify terms: heading, subheading, body text, button label, home page, main menu, footer menu, cart type, social media.
- Locale keys:
area.component.key. Every storefront string goes through{{ 'key' | t }}.
CSS
- Native CSS only. No Sass, no framework, no minification.
- Never use the
{% stylesheet %}tag. Shopify compiles every{% stylesheet %}tag of a theme into one file that is linked fromcontent_for_headeron every page and blocks rendering: a product page then pays for the styles of home page blocks, and the file grows with every block.scripts/check-no-stylesheet-tag.mjsfails the build when the tag comes back. - Styles live in
assets/, in three kinds of files:base.css, loaded in the head on every page withstylesheet_tag, abovecontent_for_header. It holds what every first screen needs: tokens, reset, base type, layout, shared controls, header, breadcrumb, section containers. It declares@layer reset, base, layout, components, utilities.- One page file, loaded in the head with the base file, for the first screen of a page type:
product.css(gallery, buy area),collection.css(collection and search),home.css(hero, facts). - One small file per block, snippet, or section (
block-<name>.css,snippet-<name>.css,section-<name>.css), loaded with{{ '<file>' | asset_url | stylesheet_tag }}right before the markup it styles, inside the same condition, so an empty block loads nothing. The link is synchronous: the block is never painted without its styles, wherever a merchant moves it. Never defer or lazy-load a stylesheet.
- A child-only block (
_fact,_step,_faq-item) and a snippet rendered in a loop (product-card,article-card,product-row,spec-rows,compatibility-row) do not load a file themselves: their styles are in the parent's file, or the parent loads the snippet's file once before the loop. - A block whose styles are in a page file loads that page file itself when it is rendered on another page type (see
sections/hero.liquidandblocks/featured-product.liquid). - Styles of content that arrives later through the Section Rendering API (cart drawer, predictive search, recommendations) are loaded by the element already in the page, so the content never shows unstyled.
- Keep
{{ content_for_header }}after the first-screen stylesheets, and do not inline them. Whilebase.cssand the page file load, the browser also holds back Shopify's own scripts, the block stylesheets, and the fonts, so the largest image of the first screen has the line almost to itself. Measured on 23/11/2026 with real throttling: with the same CSS inlined in a<style>tag, first paint came 650 ms sooner but the largest image took 1.4 to 2.3 s longer, because 30 scripts and 15 stylesheets were served before it. The LCP comes first: it is what Google and the merchant's speed report keep. Do not movecontent_for_headerup, and do not inline CSS, without measuring the LCP (LH_THROTTLING=devtools node scripts/lighthouse.mjs). - A new block means a new CSS file and one
stylesheet_tagline.scripts/check-asset-budgets.mjslimits the first-paint CSS and the total of block files. - Mobile first.
min-widthmedia queries only (700px, 1000px). Logical properties. Container queries for components.svhanddvhfor viewport heights.env(safe-area-inset-*)for anything fixed to an edge. - Hover effects only in
@media (hover: hover). Animatetransformandopacityonly. Respectprefers-reduced-motion.
JavaScript
- The store works without JavaScript: content is in the HTML, forms post natively, disclosure uses
<details>, overlays use<dialog>and thepopoverattribute. - One custom element per interactive component, in
assets/<name>.js, listed insnippets/import-map.liquidas@theme/<name>. No framework, no bundler. Do not loades-module-shims: Shopify provides it. - Opt in from markup:
<my-component data-module="my-component" data-load="interaction|visible|idle">.assets/loader.jsimports the module on demand. Nothing else runs on first paint. - Build the DOM of drawers, filters, and dialogs on first open. Use passive listeners, debounce input handlers, and split long tasks.
- Never inject content that matters (price, text, structured data) with JavaScript.
- Never modify, wrap, or parse
{{ content_for_header }}.
Liquid performance
- The first image of the first screen:
loading: 'eager',fetchpriority: 'high', no entrance animation, never a CSS background. Other images are lazy, chosen withsection.indexandsection.location. - Images use
image_urlwithimage_tag, withwidths,sizes, andaltfromimage.alt.widthsreplaces the defaults: keep sizes that are smaller than the source. - No nested loops. No metafield access inside a loop. Use
limitandpaginate. Assign before the loop. Keeprendercalls flat. - Keep the layout head cheap: no loops over products, collections, or variants above
content_for_header. - Preload one or two resources at most.
- Fonts: a font that has fallback fonts with matched metrics loads after the largest image of the first screen (
assets/loader.jsadds the classfonts-ready;snippets/font-fallbacks.liquidholds the table, two fallbacks per font, of the same kind as the font: Arial and Roboto for sans-serif, display, and handwriting fonts, Times New Roman and Noto Serif for serif fonts, Courier New and Roboto Mono for monospace fonts; the first of each pair is for Apple and Windows, the second for Android). The table is generated: never edit it by hand, runnode scripts/build-font-fallbacks.mjs. A font outside the table loads at once and is preloaded. Do not preload a font that waits, and do not add a font weight without checking the fallback: a text that changes width when the font arrives is a layout shift.setup/fonts.jsonlists the covered fonts. - Colors: never output a text color straight from a setting.
snippets/css-variables.liquidpasses every text color throughsnippets/readable-color.liquid, which replaces a color under 4.5:1 with black or white. A new text color token follows the same path, and the readiness panel counts it. - Brand settings of the Shopify admin (
shop.brand): logo, square logo (favicon), short description, and social links are used when the matching theme setting is empty. Colors are used only with the setting "Use brand colors". The slogan becomes the title of the home page only when that title (the Heading 1 of the home page) is empty, and it is declared in the organization data. The theme setting always wins. Read a social link withsnippets/social-url.liquid, never fromsettingsdirectly.
Accessibility (WCAG 2.2 AA)
- Everything works with a keyboard. Focus is visible and never hidden by a sticky bar. Focus order equals DOM order.
- One
h1per page. No skipped heading level. - Text contrast 4.5:1. Large text, icons, and borders 3:1. State is never shown by color alone.
- Targets are 48 by 48px, never under 24 by 24px. Form fields are 16px or larger.
- Inputs have a unique id and a label with a matching
for. Errors say what is wrong. - Cart and price updates are announced with
aria-live. Dialogs trap focus and return it to the control that opened them. - Carousels have previous and next buttons and never move on their own.
GEO and SEO
All useful content is in the server-rendered HTML: description, specs, compatibility, questions, delivery, returns, price, stock.
Answer first: the quick answer states what the product is, who it is for, and what is included.
Measurable facts, not slogans. Nothing invented: no fake reviews, ratings, stock levels, countdowns, or urgency.
The visible page, the structured data, the store policies, and the merchant feeds must say the same thing. Delivery and returns values come from the Shipping and Returns theme settings everywhere.
Structured data is JSON-LD written in Liquid, in dedicated snippets, one block per type per page, with absolute URLs. Never from JavaScript. Ratings appear only when
product.metafields.reviews.rating_countis greater than 0.snippets/structured-data.liquidis rendered once at the end of the layout body and picks the blocks by page type:Page Blocks Snippet Home OnlineStore(the organization),WebSitejsonld-organizationProduct Product, orProductGroupwith oneProductand oneOfferper variant, plusBreadcrumbListjsonld-product,jsonld-offer,jsonld-breadcrumbCollection CollectionPagewithItemList, plusBreadcrumbListjsonld-collectionArticle Article, plusBreadcrumbListjsonld-articleAny page with a Questions block fed by a metafield FAQPage, written byblocks/faq.liquidfrom the entries it showsfaqblockWhat feeds the structured data: Brand identity, Logo, and Social media settings feed the organization. Shipping and Returns settings feed
shippingDetailsandhasMerchantReturnPolicyon every offer (snippets/jsonld-policies.liquid). The product feeds name, description, images, category, SKU, barcode (gtin), price, regular price when on sale, and availability.brandcomes from the product metafieldcustom.brandonly, never from the vendor field.Never use
AggregateOffer, never output an empty value, never addpriceValidUntilor a rating that the store's data does not hold.Always build URLs with
routes. Link to products withproduct.url.The theme does not ship
templates/agents.md.liquidortemplates/robots.txt.liquid. Shopify maintains the defaults.
Settings map (theme settings)
| Group | Ids | Used by |
|---|---|---|
| Colors | color_* |
snippets/css-variables.liquid |
| Typography | type_heading_font, type_body_font, type_data_font, type_body_size |
snippets/css-variables.liquid |
| Layout | layout_page_width |
.page-width |
| Logo and favicon | logo, logo_width, favicon |
header, layout head |
| Product | product_image_fit, product_blend_images |
galleries and cards |
| Cart | cart_type |
cart drawer or cart page |
| Social media | social_*_link |
footer icons, sameAs in structured data |
| Brand identity | brand_legal_name, brand_description, brand_email, brand_phone, brand_address_* |
Organization structured data |
| Shipping | shipping_countries, shipping_handling_days_min and _max, shipping_transit_days_min and _max, shipping_business_days, shipping_rate, shipping_free_threshold |
delivery summary near the buy button, shippingDetails |
| Returns | returns_days, returns_fees, returns_shipping_fee, returns_method, returns_countries, returns_policy_url |
returns summary, hasMerchantReturnPolicy |
When you configure a store: enter only facts that match the store's legal pages and Shopify settings. Leave a field empty rather than guess. An empty field is omitted from the page and from the structured data.
Configuring a store
When the task is to set up a store, not to change code, follow setup/AI-SETUP.md of the theme documentation. In short:
- Theme settings first: identity (Logo and favicon, Colors, Typography), Brand identity, Social media, Shipping, Returns. They live in
config/settings_data.jsonundercurrent. Write them on an unpublished copy of the theme, or in the theme editor. - Metafield and metaobject definitions next (
setup/metafields.json), then the values, product by product, from the merchant's own documents. - Templates last: each JSON template lists sections, each section lists blocks. Add a GEO block where its facts exist. A block without data renders nothing on the storefront and shows help in the theme editor.
- Finish with proof:
node setup/checks/run.mjs, then the readiness panel of the theme editor, which lists what is still missing on the page.
Rules: ask before every write, say what will change, never invent a value, and keep the page, the structured data, and the store policies saying the same thing.
Do not
- Do not write to a published theme. Push with
shopify theme push --unpublishedor to an unpublished theme id. Never use--allow-live. Never runshopify theme publishwithout the owner's written approval. - Do not change store data (products, orders, settings) without explicit approval.
- Do not commit secrets.
.envis ignored by Git. - Do not add a designer credit, an affiliate link, or a feature that needs an app or an API.
- Do not add a font outside the Shopify font picker.
Checks
Run from the repository root (the folder above theme/).
shopify theme check --path theme Liquid, schema, asset sizes
node scripts/check-generic.mjs no store-specific data in theme/
node scripts/check-no-stylesheet-tag.mjs no {% stylesheet %} tag anywhere
node scripts/check-asset-budgets.mjs strict size budgets for the theme's own JavaScript and CSS
npx playwright test small screens first, axe-core (needs BASE_URL)
npm run test:cart-live the one test on a real cart, on the reference Mac, before a merge
node scripts/check-jsonld.mjs <url> structured data: valid, one block per type, required fields
node scripts/check-no-js.mjs <url> title, price, description, GEO blocks in the raw HTML
node scripts/check-images-alt.mjs <url> every image has a description
node setup/checks/run.mjs --store <url> --product <path> all final checks of a configured store
.theme-check.yml extends theme-check:recommended. Fix the Liquid instead of adding exceptions.
The accelerated checkout button is never rendered with the product page. {{ form | payment_button }} in the page makes Shopify add an 83 KB script and a stylesheet to the head. The button lives in sections/product-payment-button.liquid and is fetched by assets/express-payment.js after the first-screen image, into a slot of the final height. Do not put payment_button back in a block or a section that renders with the page.
No test changes a real cart in CI. Shopify's bot protection challenges cart changes made by an automated browser from shared addresses, then every page that follows. The tests of the cart interface replay responses recorded on the store (tests/cart-replay.mjs, tests/recordings/cart.json). When you change the cart markup or the cart JavaScript, run npm run test:cart-live on the reference Mac: it follows a real purchase up to the checkout button, with and without JavaScript, and records the responses again. Commit the recording when it says it changed. Run it once per merge, not more: three real runs within an hour got the reference Mac challenged too (24/11/2026).
How a change of loading order is judged. For a change that only moves when something loads (a script, a font, a stylesheet, a button), two measures are needed, both by the comparison rules (scripts/lighthouse-compare.mjs: copies in alternation, a pair of identical copies for the noise). The standard script must show no loss beyond the noise, and real throttling (LH_THROTTLING=devtools) must show a gain beyond the noise. The simulated model of the standard script does not see resources competing for the line: real throttling is what measures it.
Every optimization has a test that proves it is active in the page as served. A speed or loading optimization (late fonts, a deferred script, a lazy image, a preload that was removed) can be switched off by one condition that never matches, and nothing looks broken. So each one comes with a test that reads the served HTML or the loaded page and checks the optimized state itself, like web fonts wait for the first-screen image in tests/foundation.spec.mjs. A measure alone is not a proof: it only says the page was fast that day.