Shopify 6 min read

Building a custom Shopify theme section with Liquid

How to build a custom Shopify theme section with Liquid and a schema block, so store owners can add and edit it in the theme editor without code.

Usman Muhammad UsmanUpdated October 13, 2026
Building a custom Shopify theme section with Liquid

Online Store 2.0 themes are built from sections that store owners can add, reorder and edit in the theme editor. When a theme does not include the section a client needs, I build a custom one rather than installing an app. A well-built section is fast, editable without code and survives theme updates. This guide walks through how I do it.

How sections work in Online Store 2.0

Every page in a modern Shopify theme is made of sections listed in a JSON template, such as templates/product.json or templates/index.json. Each section is a Liquid file in the sections folder with two parts: the HTML and Liquid markup that renders it, and a schema block in JSON that defines the settings shown in the theme editor.

Because templates are JSON, merchants can add, remove and reorder sections on any page type without touching code. A custom section therefore becomes a reusable building block: build it once and the store owner can use it on the homepage, a collection page or a landing page whenever they need it.

Planning the section

Before writing code, decide what the merchant needs to edit. A testimonial section might need a heading, a background colour and a list of testimonials, each with a quote, name and photo. A size guide might need a table and an image. List every setting and whether it applies to the whole section or to repeatable items, which become blocks.

Look at the theme’s existing sections for patterns to follow. Matching the theme’s class names, spacing settings and colour schemes keeps the new section visually consistent and lets it inherit theme styles. Dawn and other free Shopify themes are good references for clean, accessible section code.

Building a custom section
  1. 1Plan settingsSection vs block settings
  2. 2Write schemaSettings, blocks, presets
  3. 3Liquid markupResponsive images, empty states
  4. 4Scoped CSS and JSOnly what is needed
  5. 5Test in editorTheme Check and devices

Writing the schema

The schema block at the bottom of the file lists settings such as text, richtext, image_picker, color_scheme, range, select and url. Give each setting an id, a label and a sensible default. Add blocks for repeatable content, with their own settings, and set a max_blocks limit if the design needs it.

Include a presets entry so the section appears in the ‘Add section’ menu in the theme editor. Use the enabled_on or disabled_on properties to control which templates and section groups it can be added to. Clear labels and info text make the section easy for non-technical merchants to use.

Writing the Liquid markup

In the markup, access settings with section.settings.id and loop through blocks with for block in section.blocks. Output block.shopify_attributes on each block wrapper so the theme editor can highlight and select blocks. Use the image_url and image_tag filters with width and sizes attributes for responsive images.

Escape user content where needed and handle empty states, so the section does not show broken layouts when a setting is blank. Keep markup semantic, with proper heading levels and alt text, which helps accessibility and the Shopify SEO basics I set up on every store.

Styles and scripts

Keep CSS scoped to the section with a unique class or by using the section.id, so styles do not leak into other parts of the theme. Small amounts of CSS can live in a stylesheet tag inside the section; larger styles belong in a dedicated asset file loaded only when the section is used.

Avoid JavaScript unless the section genuinely needs interactivity, such as a slider or tabs. When it does, use a small script with the defer attribute or a custom element, and make sure it works when the section is added or reloaded in the theme editor by listening for the shopify:section:load event.

Using metafields and dynamic sources

Sections become much more powerful with metafields. A product page section can display a size guide, ingredients or care instructions stored in product metafields, so each product shows its own content using one shared section. Merchants connect settings to metafields through dynamic sources in the theme editor.

Define metafields under Settings > Custom data with clear names and types. My guide to Shopify metafields and metaobjects explains how to structure them. This approach replaces many apps that exist only to add extra product information.

Testing in the theme editor

Work on a duplicate of the live theme or a development theme using Shopify CLI, which gives you a live preview and hot reloading. Add the section in the theme editor, try every setting, add and remove blocks, and check empty states. Test on mobile and desktop and with real content lengths.

Check performance with Lighthouse or PageSpeed Insights, especially if the section includes images or scripts above the fold. Run Theme Check, part of Shopify CLI, to catch common Liquid errors and performance issues before publishing.

Sections vs apps

Many apps add sections or blocks through theme app extensions, which is convenient but adds a monthly fee and often extra scripts. For content that is mostly static, such as testimonials, FAQs, comparison tables or trust badges, a custom section is faster and has no ongoing cost.

I weigh this decision in Shopify apps vs custom code. Apps make sense when the feature needs a backend, such as reviews, subscriptions or loyalty programmes. Display-only features are usually better as sections.

Keeping custom sections safe during updates

Theme updates from the developer can overwrite modified files, but new section files you add are usually kept if you update carefully. Keep a copy of every custom section in version control or a documented folder, and note which theme files you changed so they can be reapplied after an update.

If you would like custom sections built for your store, they are a core part of my Shopify development service. You can see examples of custom Shopify work in my portfolio.

Key takeaways

  • Online Store 2.0 sections can be added to any JSON template.
  • Plan which settings merchants need before writing code.
  • Use metafields so one section shows different content per product.
  • Prefer custom sections over apps for display-only features.

Frequently asked questions

Do I need to know Liquid to build a section?

Yes, basic Liquid, HTML and CSS. Shopify's documentation and the Dawn theme are excellent references.

Can sections be used on every page?

In Online Store 2.0 themes, yes. Sections can be added to any JSON template, including product and collection pages.

Will a custom section slow my store?

Not if it is built carefully with responsive images and minimal JavaScript. Most custom sections are lighter than equivalent apps.

What is Shopify CLI?

A command-line tool for developing themes locally with live preview, syncing and Theme Check linting.

Can I sell or reuse a section on other stores?

You can reuse your own code on other stores you build. Check the theme licence before copying code from paid themes.

Free website audit

Get a free audit of your website

Tell me your URL and I'll send a short, prioritized list of the speed, SEO and security fixes that will make the biggest difference.

  • No obligation, no sales call
  • 5.0 rating on Google and Upwork
  • Reply within one business day
Written by Muhammad UsmanWeb Development Team Lead with 5+ years building WordPress, WooCommerce, Shopify and Wix websites. Experience · Certificates About me

More on Shopify

All Shopify articles

Have a project in mind?

Tell me what you're building and I'll reply with next steps and an estimate.