BlogShopify development

Shopify Sections and Blocks Explained: How They Work, With Code

A Shopify section is a Liquid file that renders one part of a page, and blocks are the smaller pieces merchants add and reorder inside it. This guide shows the for block in section.blocks loop, what block.shopify_attributes does, and how section, theme and app blocks differ.

Work with Ecompanda
Copy as MarkdownSet as Preferred Source
Stacked green and off-white rounded panels with smaller blocks sitting on and inside them, and one small chartreuse block, on a pale floor

Sections and blocks in short

Generated by Ecompanda AI

A section is a Liquid file that renders one full-width part of a Shopify page, and blocks are the pieces merchants arrange inside it. A section renders its own blocks with a for loop over section.blocks, and each block's outer element needs block.shopify_attributes so the theme editor can find it.

  • Online Store 2.0 JSON templates list which sections a page shows and in what order
  • Section blocks live in one section's schema and cannot nest
  • Theme blocks are files in /blocks, render with content_for 'blocks' and can nest up to 8 levels
  • App blocks need an @app entry in the schema, and a looping section must render them with render block
  • One section uses section blocks or theme blocks, not both

A Shopify section is a Liquid file that renders one full-width part of a page, such as a slideshow or an FAQ. A block is a smaller piece inside a section, like a slide, a question or a column, that merchants add, remove and reorder in the theme editor. The section draws its blocks with a loop, {% for block in section.blocks %}, and picks the markup for each one by block.type.

Below we show that loop in a complete section, explain block.shopify_attributes, and compare the three kinds of block. Then we cover the JSON templates and limits around them. If Liquid tags like case are new to you, our Liquid guide is the better place to start.

Looping over blocks: for block in section.blocks

To render a section's own blocks, loop over section.blocks, branch on block.type, and put {{ block.shopify_attributes }} on each block's outer element. That's the whole pattern.

Here it is in a complete FAQ section. It follows Shopify's section schema reference. Try it in a development theme before you ship it.

<div class="faq">
  {% for block in section.blocks %}
    {% case block.type %}
      {% when 'question' %}
        <details {{ block.shopify_attributes }}>
          <summary>{{ block.settings.title | escape }}</summary>
          {{ block.settings.answer }}
        </details>
      {% when '@app' %}
        {% render block %}
    {% endcase %}
  {% endfor %}
</div>

{% schema %}
{
  "name": "FAQ list",
  "blocks": [
    {
      "type": "question",
      "name": "Question",
      "settings": [
        { "type": "text", "id": "title", "label": "Question" },
        { "type": "richtext", "id": "answer", "label": "Answer" }
      ]
    },
    { "type": "@app" }
  ],
  "max_blocks": 12,
  "presets": [
    {
      "name": "FAQ list",
      "blocks": [{ "type": "question" }, { "type": "question" }]
    }
  ]
}
{% endschema %}

What each part does:

  • for block in section.blocks walks the blocks in the order the merchant arranged them. A section holds up to 50 blocks, and max_blocks lowers that cap.
  • case block.type picks the markup. The type is the type you set in the schema. Never test block.id against a fixed string, because Shopify generates IDs and says they can change.
  • {{ block.shopify_attributes }} sits on the block's outermost element, here the <details>. Without it the theme editor can't tie that element to the block.
  • when '@app' with {% render block %} lets app blocks show up in a section that loops over its own blocks. The { "type": "@app" } entry in the schema is what allows merchants to add them.
  • presets puts the section in the editor's Add section list.

One small trick is in there too. The editor sidebar names each block after a setting with the id heading, then title, then text, and falls back to the block name. We used title, so each block shows its actual question instead of "Question".

What is block.shopify_attributes?

block.shopify_attributes prints the data attributes the theme editor uses to identify a block. Put it on the block's outer element so the editor can link that element to the block, for example when a merchant selects the block in the sidebar and the shopify:block:select event fires. Outside the theme editor it prints nothing, so shoppers never see it.

Shopify's block object reference and its page on integrating sections and blocks with the editor both say this. Sections get the attribute on their Shopify-made wrapper automatically. Section blocks don't, so you add it by hand.

Theme blocks (more on those below) are wrapped in a Shopify <div> by default. If you switch that wrapper off with "tag": null, add the attribute yourself to the single top element of the block file.

The same loop in Dawn

Shopify's Dawn theme uses the same loop and attribute, and its code is public on GitHub. In sections/multicolumn.liquid, line 59 opens {%- for block in section.blocks -%} and line 72 puts {{ block.shopify_attributes }} on each column's <li>.

Dawn's multicolumn.liquid file on GitHub, with a for block in section.blocks loop and block.shopify_attributes on each list item
Dawn loops over the same blocks twice: once to find the highest image aspect ratio, once to render the columns.

Look at lines 51 to 58 as well. Dawn loops over the blocks once before rendering anything, only to work out the highest image aspect ratio. So you can loop as often as you need. Line 70 shows another habit worth copying: forloop.index gives each block a number for its HTML id.

If you're editing Dawn itself, our Dawn customisation guide covers the safer ways to do it.

How a page is built in Online Store 2.0

In a current theme, most page types use a JSON template, a data file that lists which sections a page shows and in what order. JSON templates arrived with Online Store 2.0, and they're why merchants can add, remove and reorder sections on most pages from the theme editor.

Four layers decide what a visitor sees:

  1. A layout (usually layout/theme.liquid) is the frame around every page.
  2. Section groups fill the parts of the frame that repeat, normally the header and footer.
  3. A template fills the middle. In an Online Store 2.0 theme it's a JSON file that lists sections.
  4. Sections hold the markup and settings, and blocks are the pieces merchants arrange inside them.
A layout containing a header group, a product template with two sections holding blocks, and a footer group
How a layout, section groups, a JSON template, sections and blocks nest, an Ecompanda diagram

Upgrading to Online Store 2.0 isn't mandatory, and older "vintage" themes keep working. Our Online Store 2.0 guide covers what else changed.

JSON templates

A JSON template has two required keys. sections is an object whose keys are section IDs, and order lists those IDs in render order. Each section entry names its type (the section's filename without .liquid), its settings, its blocks and a block_order.

{
  "sections": {
    "main": {
      "type": "main-product",
      "settings": {}
    },
    "faq": {
      "type": "faq-list",
      "blocks": {
        "q1": {
          "type": "question",
          "settings": { "title": "Do you ship worldwide?", "answer": "<p>Answer goes here.</p>" }
        },
        "q2": {
          "type": "question",
          "settings": { "title": "How do I care for it?", "answer": "<p>Answer goes here.</p>" }
        }
      },
      "block_order": ["q1", "q2"]
    }
  },
  "order": ["main", "faq"]
}

Shopify renders the sections in order with no markup between them. A section marked "disabled": true is skipped on the page but stays editable. The template can also name a different layout, or false for none, though those pages can't be customised in the editor.

Section groups

A section group is the same idea for the repeating parts of a layout. It's a JSON file in sections/ with a type (header, footer, aside or custom.<name>), a name, sections and order. You place it in the layout with one tag:

{% sections 'header-group' %}

Shopify suggests using groups only for the header and footer in most themes. Inside a group, merchants can add and reorder sections, which is how an announcement bar ends up above the header with no code change.

Static and dynamic sections

A dynamic section is listed in a JSON template or section group, so merchants control it. A static section is rendered straight from Liquid with {% section 'featured-product' %}.

Merchants can't move or remove a static section. There's also only one instance of it, so changing its settings in one place changes it everywhere it appears. Shopify's advice is to avoid static sections and move old ones into section groups. We'd follow it for anything a merchant might one day want to move.

Section schema: the keys that matter

Every section file needs exactly one {% schema %} tag holding valid JSON, and it can't sit inside another Liquid tag. Two schema tags, or a nested one, is a syntax error. These are the keys you'll use most:

KeyWhat it does
nameThe title in the editor. Capped at 25 characters.
tagThe wrapper element: article, aside, div, footer, header or section. Default is a div.
classExtra classes on the wrapper, after shopify-section.
limit1 or 2, to cap how often the section can be added.
settingsSection-wide options. Each setting id must be unique in the section.
blocksThe blocks the section accepts.
max_blocksLowers the default cap of 50 blocks.
presetsStarting points. Without one, merchants can't add the section in the editor.
defaultStarting settings for a section you render statically.
enabled_on / disabled_onLimit the section to, or keep it off, certain templates and groups. Use one, not both.
localesTranslations that travel with the section.

Section blocks, theme blocks and app blocks

Shopify has three kinds of block. Section blocks are defined inside one section's schema, like the FAQ above. Theme blocks are their own files in /blocks, reusable across sections and able to nest. App blocks come from apps installed on the shop.

Section blocksTheme blocksApp blocks
Defined inThe section's schemaTheir own file in /blocksAn app's theme app extension
ReusableOnly in that sectionAcross sections and blocksWherever a schema accepts @app
Can nestNoYes, up to 8 levelsn/a
Rendered withfor block in section.blockscontent_for 'blocks'content_for 'blocks', or render block in a loop
Best forSimple lists: slides, FAQsFlexible layoutsContent an app provides

One rule catches people out. A section either defines its own blocks or accepts theme blocks, not both, and Shopify's blocks overview says so. To move an older section to theme blocks, you convert its blocks rather than add to them.

Theme blocks and content_for 'blocks'

A theme block is a file in /blocks with markup and a schema. It reads its own settings through the block object. Here's a card block, then a section that holds cards:

<h3>{{ block.settings.heading }}</h3>
{{ block.settings.text }}

{% schema %}
{
  "name": "Card",
  "tag": "article",
  "class": "feature-card",
  "settings": [
    { "type": "text", "id": "heading", "label": "Heading", "default": "Free returns" },
    { "type": "richtext", "id": "text", "label": "Text" }
  ],
  "presets": [{ "name": "Card" }]
}
{% endschema %}
<div class="feature-columns" style="--columns: {{ section.settings.columns }}">
  {% content_for 'blocks' %}
</div>

{% schema %}
{
  "name": "Feature columns",
  "settings": [
    { "type": "range", "id": "columns", "label": "Columns", "min": 1, "max": 4, "step": 1, "default": 3 }
  ],
  "blocks": [{ "type": "_card" }, { "type": "@app" }],
  "presets": [
    { "name": "Feature columns", "blocks": [{ "type": "_card" }, { "type": "_card" }, { "type": "_card" }] }
  ]
}
{% endschema %}

Notice there's no for loop. {% content_for 'blocks' %} renders every block the merchant added, app blocks included, in their saved order. Three details make it work:

  • Presets make a theme block selectable. A theme block shows in the block picker only if it defines presets. A preset can include child blocks, which is how you ship ready-made nested layouts.
  • @theme and named types set what's allowed. { "type": "@theme" } accepts every theme block. Naming one ("type": "_card") accepts only that block.
  • An underscore makes a block private. A file like _card.liquid is left out of the picker for @theme sections and appears only where a schema names it. Good for pieces like slides that only make sense in one place.

To nest, give a theme block its own blocks array and render its children with {% content_for 'blocks' %}. Shopify allows 8 levels below the section. We'd stop at two or three. Every extra level is one more thing a merchant can rearrange into a broken-looking page.

Theme blocks aren't snippets. They show settings in the editor, but a block rendered by content_for 'blocks' can't receive variables from the code around it. Use snippets for repeated markup and blocks for things merchants should edit.

Static blocks

A static block is a theme block you render in a fixed spot, with an id you choose:

{% content_for 'blocks' %}

{%- if section.blocks.size > 1 -%}
  {% content_for 'block', type: '_slideshow-controls', id: 'controls' %}
{%- endif -%}

Merchants can hide and edit a static block, but not drag, remove or duplicate it. Because it's plain Liquid, you can wrap it in an if or a loop and pass it parameters. Static blocks also don't count toward the section's block limit.

Shopify's table comparing static blocks with dynamically rendered blocks
Static versus dynamically rendered theme blocks, shopify.dev

In saved JSON, static blocks carry "static": true and stay out of block_order, because nobody can reorder them.

Theme block settings can also pull live data, such as the product on the page or a metafield. Inside a nested block you often can't tell where that data came from, so Shopify provides a closest path that finds the nearest resource of a given type.

App blocks

App blocks let an app add content to a theme without editing theme code. Apps build them with theme app extensions. A section or theme block accepts them through one schema entry:

"blocks": [{ "type": "@app" }]

The rules from Shopify's app blocks page:

  • @app blocks can't take a limit. Adding one is an error.
  • They don't work in statically rendered sections.
  • content_for 'blocks' renders them for you. A section that loops over its own blocks needs the when '@app' branch from our FAQ example.
  • When a merchant adds an app as its own section, Shopify wraps it in an apps.liquid section. You can supply your own, but it must accept @app blocks and have a preset. Without one, Shopify looks for _blocks.liquid.

Shopify's advice is to offer app blocks where an app can help a purchase, such as the product page. Skip them in layouts that would break when an unexpected block turns up.

Theme blocks so far, and the block and partial tags

DateWhat changedSource
31 January 2024Theme blocks announced in developer preview, with nesting up to 8 levelsShopify Partners blog
21 May 2025Recommended blocks in the picker, block previews, parameters for static blocksShopify changelog
21 July 2026Liquid July '26 developer preview adds the block and partial tagsShopify changelog

The July 2026 preview lets a Liquid template compose a page directly with {% block %} instead of listing sections in JSON. {% partial %} marks a region JavaScript can refresh without a full reload.

Shopify says existing themes keep working with sections, theme settings and JSON templates. It's still a preview, so don't rebuild a live theme around it yet.

Shopify's developer preview page describing the block and partial tags
The Liquid developer preview page, shopify.dev

We couldn't find a dated note saying theme blocks left preview, but Shopify's current docs treat them as a normal feature.

Limits worth knowing

LimitValue
JSON templates per theme1,000
Sections per JSON template or section group25
Blocks per section50
Blocks per JSON template or section group1,250
Section groups per theme20
Theme block files in /blocks300
Section or block schema name25 characters
JSON template or section group file512 KB
Other Liquid files256 KB
Shopify's theme limits table for blocks
Section and block limits, shopify.dev

Going over a limit gives an error in the editor or when the theme is saved or uploaded. Every .liquid file in /blocks counts toward the 300, including unused and AI-generated blocks. The full list is on Shopify's theme limits page.

Mistakes we'd avoid

  • JavaScript that only runs on page load. The editor re-renders sections in place. Listen for shopify:section:load and shopify:section:unload, and check Shopify.designMode in JavaScript or request.design_mode in Liquid to detect the editor.
  • Over-granular blocks. Author, date and comment count belong in one block, not three.

Frequently asked questions

What is the difference between a section and a block?

A section is a Liquid file that forms a full-width part of a page, added to a template or section group. A block is a smaller piece inside a section, such as a heading, a button or a slide. Merchants arrange sections on the page and blocks inside a section.

Why can't the theme editor identify my block?

Usually the block's outer element is missing {{ block.shopify_attributes }}. The editor looks for that data attribute to identify blocks, so without it the editor can't tell which element belongs to the block. Add it to the top element inside your for loop, or to the single top element of a theme block that uses "tag": null.

Can I use section blocks and theme blocks in the same section?

No. Shopify says a section can define blocks locally or accept theme blocks, but not both at once. A theme can mix the two across different sections.

Why doesn't my section appear in the Add section list?

Most often the schema has no presets, or enabled_on or disabled_on excludes the current template. Also check the schema is valid JSON with a single schema tag.

Do app blocks work in every section?

No. The section or theme block must include { "type": "@app" } in its schema, and statically rendered sections can't take app blocks at all. Merchants can still add an app as its own section, wrapped by apps.liquid.

What are Online Store 2.0 sections?

They're the same sections. Online Store 2.0 brought JSON templates, which let merchants add, remove and reorder sections on most pages from the theme editor. It also brought app blocks and dynamic sources.

Will the new block and partial tags replace sections?

Shopify hasn't said so. The July 2026 developer preview adds the tags alongside the current model and says sections, theme settings and JSON templates keep working.

How do I know if my theme uses theme blocks?

Open the theme's code editor and look for a blocks folder in the sidebar. If it's there, the theme supports theme blocks, though some sections may still use section blocks.

Where we can help

We build and maintain Shopify themes, including custom sections and theme blocks merchants can edit without a developer. If you want a section built properly or an old theme moved to blocks, get in touch. For the bigger picture, read our overview of custom theme development.

Sources

The Shopify pages this guide rests on. Check the current version before you rely on a detail.

← All guidesMore on shopify development

Related content

More on shopify development

All guides

Shopify development

Shopify Liquid cheat sheet and guide: syntax, tags, filters and objects

Shopify Liquid is the template language Shopify themes use to turn store data into HTML. This page gives you a cheat sheet of its syntax, tags, filters, objects and comments, then the patterns and checks that keep theme code working.

Shopify development

Shopify Theme Customization: A Safe Workflow and Review Checklist

To customize a Shopify theme safely, use the theme editor first, do code work on a copy, run Theme Check and a review checklist, then publish with the old theme kept for rollback. This guide covers each step and what to do when a theme won't stretch far enough.

Free newsletter

Enjoying this guide? Get one tactic like it every week.

Short notes on Shopify, AI search and conversion, taken from our own work. Unsubscribe in one click.

Let’s make your store your best salesperson.

Tell us where your brand is headed in the next twelve months and we will show you how your store can get it there. Book a 15 minute call or send us a message, and we reply within one business day.

Replies within one business day