Skip to content

Shopify theme architecture

A Shopify guide for coding agents. Also covers theme architecture, shopify directories, online store 2.0, json templates.

Use this guide when creating, moving, or connecting files in an Online Store 2.0 theme. Shopify's current documentation is the source of truth; confirm unfamiliar or recently added APIs there before coding.

Use the supported directory model

A theme may use assets, blocks, config, layout, locales, sections, snippets, and templates. Customer templates live under templates/customers, and metaobject templates can live under templates/metaobject. Do not invent parallel source directories inside the uploaded theme. Build tools may keep source elsewhere, but their output must land in Shopify's supported structure.

  • layout/theme.liquid is the storefront shell. It must render content_for_header inside <head> and content_for_layout in the body.
  • templates/*.json compose pages from sections and let merchants reorder or configure them.
  • Liquid templates remain appropriate for layouts and Shopify template types that do not support JSON.
  • sections/*.liquid are merchant-configurable page modules. Section groups such as header-group.json and footer-group.json compose global areas.
  • blocks/*.liquid are reusable theme blocks that sections can accept with @theme blocks.
  • snippets/*.liquid are parameterized, reusable render units. They do not appear in the theme editor.
  • config/settings_schema.json defines global theme settings. config/settings_data.json contains merchant state and should not be overwritten casually.
  • locales/*.json and *.schema.json hold storefront and theme-editor translations.
  • assets holds CSS, JavaScript, fonts, and static media that belong to the theme.

Compose JSON templates safely

A JSON template contains a sections object and an order array. Each order entry must match a key in sections. A section entry needs a valid type matching a section filename without .liquid; its optional settings and blocks must match that section's schema.

Do not treat generated JSON as comments-tolerant configuration. It must parse as strict JSON. Preserve merchant-created template instances unless the task explicitly replaces the full page composition.

Section groups follow the same composition idea and are rendered from a Liquid layout with the sections tag:

{% sections 'header-group' %}
<main id="MainContent" role="main">
  {{ content_for_layout }}
</main>
{% sections 'footer-group' %}

Use {% section 'name' %} only for a static section call. A static section is not managed like a JSON-template section instance.

Keep ownership boundaries explicit

Theme code owns storefront presentation and cart interactions. Shopify owns checkout unless the task explicitly targets an allowed checkout extension surface. Do not imitate checkout, collect payment details in theme code, or bypass Shopify's cart and checkout routes.

Work in an unpublished duplicate. Preserve {{ content_for_header }}, app blocks, app embeds, analytics hooks, and merchant settings when adapting an existing theme. Never replace settings_data.json or publish a theme without explicit approval.

Primary Shopify sources

Use this guidance in your coding agent

Install the Better Design MCP once. Your agent then loads this page with one call.

get-shopify-guide({ topic: "shopify-theme-architecture" })
claude mcp add --scope user better-design --transport http https://better-design.com/api/mcp --header "Authorization: Bearer <YOUR_API_KEY>"
Browse related design systems