Convert an HTML Section to Shopify Liquid: A Worked Example, Step by Step
Take a plain HTML hero banner and turn it into a Shopify Online Store 2.0 section with editable settings, a schema, a preset and scoped CSS. Every step shows the code before and after.
Share with Shopify developers — useful guides spread faster in theme dev communities.
What we are building
Most designs reach a Shopify developer as static HTML: a heading, a paragraph, an image and a button. That markup looks fine in a browser, but a merchant cannot change a single word of it in the theme editor. To fix that, the HTML has to become a section: a .liquid file in the theme's sections folder that reads its content from settings.
In this tutorial we convert one small hero banner by hand, one step at a time. You will see exactly what the converter automates, which makes its output much easier to review and trust.
Step 0: the starting HTML
This is the markup we start from. It has a heading, a short description, a call-to-action link and a background image.
<section class="hero">
<img class="hero__image" src="https://example.com/hero.jpg" alt="Summer collection">
<div class="hero__content">
<h1>Summer sale</h1>
<p>Up to 40% off selected styles.</p>
<a class="hero__button" href="/collections/sale">Shop now</a>
</div>
</section>
Everything a merchant might want to change is hard-coded: the words, the image URL and the link target. Our job is to move each of those into a setting.
Step 1: decide which parts should be editable
Before writing any Liquid, list the values that should change without touching code. For this hero the list is short:
- The heading text
- The description text
- The button label and the button link
- The background image
Do not make everything editable. Every setting adds clutter to the theme editor sidebar, and Shopify recommends keeping sections focused. A good rule is to expose text, images and links, and to leave layout decisions in the CSS.
Step 2: replace static values with Liquid
In a section file, merchant-editable values are read from section.settings. Each setting has an id that you choose. Replace each hard-coded value with an output tag that reads that id:
<section class="hero">
{% if section.settings.image != blank %}
{{ section.settings.image | image_url: width: 1600 | image_tag: class: 'hero__image', loading: 'lazy' }}
{% endif %}
<div class="hero__content">
<h1>{{ section.settings.heading }}</h1>
<p>{{ section.settings.text }}</p>
{% if section.settings.button_label != blank %}
<a class="hero__button" href="{{ section.settings.button_link }}">
{{ section.settings.button_label }}
</a>
{% endif %}
</div>
</section>
Three details matter here. First, images use the image_url and image_tag filters, so Shopify serves a correctly sized, responsive image from its CDN instead of one fixed URL. Second, the image and the button are wrapped in {% if %} checks, so an empty setting does not leave a broken image or an empty link on the page. Third, the original image alt text is handled by the image setting, which carries its own alt text in the theme editor.
Step 3: write the schema
The {% schema %} block is JSON at the bottom of the file. It tells the theme editor which settings exist and what they look like. Each setting needs a type, an id that matches the one used in the markup, and a label.
{% schema %}
{
"name": "Hero banner",
"tag": "section",
"class": "section-hero",
"settings": [
{ "type": "image_picker", "id": "image", "label": "Background image" },
{ "type": "text", "id": "heading", "label": "Heading", "default": "Summer sale" },
{ "type": "textarea", "id": "text", "label": "Description", "default": "Up to 40% off selected styles." },
{ "type": "text", "id": "button_label", "label": "Button label", "default": "Shop now" },
{ "type": "url", "id": "button_link", "label": "Button link" }
],
"presets": [
{ "name": "Hero banner" }
]
}
{% endschema %}
The presets array is what makes the section appear in the Add section list inside the theme editor. Without a preset, the section can only be used if it is already placed in a template file. This is the most common reason a freshly converted section seems to be missing.
Choose the setting type carefully. text is a single line, textarea is multi-line plain text, and richtext allows basic formatting. Use url for links so merchants get a link picker, and image_picker for images so they can upload from their media library. A full list of types, with examples, is in our setting types guide.
Step 4: scope the CSS
Theme CSS is global. If your section styles a bare h1 or a generic .button class, it can change other parts of the store, and the theme's own styles can leak into your section. The safe approach is to prefix every rule with the section's unique wrapper.
Shopify wraps each section in an element with the id shopify-section-{{ section.id }}. Use that id as a prefix, inside a {% style %} block:
{% style %}
#shopify-section-{{ section.id }} .hero {
position: relative;
min-height: 420px;
display: grid;
align-items: center;
color: #fff;
}
#shopify-section-{{ section.id }} .hero__image {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
#shopify-section-{{ section.id }} .hero__content {
position: relative;
max-width: 640px;
padding: 2rem;
}
#shopify-section-{{ section.id }} .hero__button {
display: inline-block;
padding: 0.75rem 1.5rem;
background: #fff;
color: #111;
border-radius: 6px;
text-decoration: none;
}
{% endstyle %}
Because every selector starts with the section id, you can drop the same section on a page twice and each copy keeps its own styling. We explain the pattern in more depth in scoped CSS for Shopify sections.
Step 5: add the file to your theme
- In the Shopify admin, open Online Store and then Themes.
- Duplicate your live theme first. Always test on a copy, never on the published theme.
- On the copy, choose Edit code.
- Under Sections, click Add a new section and name it
hero-banner. - Paste the full file: markup, the style block and the schema. Save.
- Open the theme editor, click Add section on any page, and pick Hero banner.
You should now see the heading, text, button and image fields in the sidebar. Change a value and the preview updates immediately. That is the proof the conversion worked.
The complete section file
Here is the finished file. Copy it into sections/hero-banner.liquid as a starting point.
<section class="hero">
{% if section.settings.image != blank %}
{{ section.settings.image | image_url: width: 1600 | image_tag: class: 'hero__image', loading: 'lazy' }}
{% endif %}
<div class="hero__content">
<h1>{{ section.settings.heading }}</h1>
<p>{{ section.settings.text }}</p>
{% if section.settings.button_label != blank %}
<a class="hero__button" href="{{ section.settings.button_link }}">{{ section.settings.button_label }}</a>
{% endif %}
</div>
</section>
{% style %}
#shopify-section-{{ section.id }} .hero { position: relative; min-height: 420px; display: grid; align-items: center; color: #fff; }
#shopify-section-{{ section.id }} .hero__image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#shopify-section-{{ section.id }} .hero__content { position: relative; max-width: 640px; padding: 2rem; }
#shopify-section-{{ section.id }} .hero__button { display: inline-block; padding: 0.75rem 1.5rem; background: #fff; color: #111; border-radius: 6px; text-decoration: none; }
{% endstyle %}
{% schema %}
{
"name": "Hero banner",
"tag": "section",
"class": "section-hero",
"settings": [
{ "type": "image_picker", "id": "image", "label": "Background image" },
{ "type": "text", "id": "heading", "label": "Heading", "default": "Summer sale" },
{ "type": "textarea", "id": "text", "label": "Description", "default": "Up to 40% off selected styles." },
{ "type": "text", "id": "button_label", "label": "Button label", "default": "Shop now" },
{ "type": "url", "id": "button_link", "label": "Button link" }
],
"presets": [{ "name": "Hero banner" }]
}
{% endschema %}
Mistakes to check before you ship
- Duplicate setting ids. Two settings with the same
idmake the schema invalid and the editor will refuse to load the section. - An id in the markup that is missing from the schema. The tag outputs nothing, so the text silently disappears. Search the file for every
section.settings.reference and confirm each has a schema entry. - Trailing commas in the JSON. The schema must be strict JSON. A comma after the last item is the number one cause of "invalid schema" errors.
- Missing preset. The section works in a template but does not show in Add section.
- Hard-coded colors and spacing. If a merchant needs to change these, add
colororrangesettings instead. - Heading level. A page should have a single
h1. If the section sits below the page title, use anh2instead.
How the converter fits in
Everything above is mechanical: find the text, images and links, give each one an id, output it with a Liquid tag, and write the matching schema. That repetitive work is what the HTML to Liquid converter does for you in one click. Paste the original HTML from Step 0 and you get a file very close to the one above, with indexed setting ids, a schema and a preset.
Always review the output. Automated conversion is a fast first draft, not a final answer: you still decide which fields should be editable, rename ids to something meaningful and test the section on a duplicate theme before it goes live.
Takeaway: a Shopify section is just your HTML with the changing parts replaced by section.settings tags, a schema that describes those settings, and scoped CSS. Once you have converted one section by hand, the rest follow the same pattern.
Need a hand?
If a section behaves differently in your theme, send us the code and the theme name through the contact form. You can also read about the developers behind this site on the Meet the founders page.
Topic cluster
Shopify Sections
OS 2.0 sections, JSON templates, and section architecture.
Convert your HTML to Shopify Liquid
Paste a module, generate Liquid + schema, then copy the result into your theme. Free to try—no signup required for a sample conversion.
Share
Share this guide
Found this guide useful? Share it with other Shopify developers on LinkedIn, X, or Reddit.