Skip to main content
Back to Blog
HTML to Liquid Conversion: Best Advice and Tips.
Tutorial

HTML to Liquid Conversion: Best Advice and Tips.

A guide which takes you through the process of turning static HTML into dynamic Shopify Liquid sections we will cover how to structure schema, replace hard coded content, and improve your theme.

3 min read

For merchants Dynamic Shopify Liquid sections is key to customizing themes. Out with the hard coded content in headers, images, links, and styles and in with easy updates right from the Shopify admin UI. This guide will take you through each step, also we will look at some common issues and more advanced tips.


Why HTML to Liquid Conversion is Important

Static HTML works for prototypes but themes really come into their own when merchants are able to edit content without going to a developer. In Shopify’s theme we use Liquid and a proper schema to make components which are not only reusable but also customizable.

Pro Tip: Begin with an HTML structure analysis to determine the editable components.


Step-by-step Conversion Process

1. Analyze your HTML structure

Every editable components requires a schema setting

  • Text content: headings, paragraphs, button text
  • Images: hero images, product photos, icons
  • Links: button URLs, nav links
  • Colors & options: background, text color, accent colors

2. Create schema settings

For each schema setting, create an editable portion, like in the example below

{
  "type": "text",
  "id": "heading",
  "label": "Section Heading",
  "default": "Welcome to Our Store"
}

3. Make Static Content to dynamic

Before (Static HTML):

<h2>Welcome to Our Store</h2>

After (Dynamic Liquid):

  <h2>{{ section.settings.heading }}</h2>

4. Most Common Mistakes to Avoid

  1. Default values in your schema are essential; they stop empty UIs.
  2. Always check your JSON schema for validity.
  3. Always test the section in the theme customizer before going live to avoid unnecessary fixes.

5. Recommended Practices

  1. Conditional Logic
  • Sections are smarter when they render parts of the UI depending on certain shopify input settings.
{% if section.settings.heading != blank %}
  <h2>{{ section.settings.heading }}</h2>
{% endif %}
  1. Image Optimization
{%- liquid
  assign widths = '375, 550, 750, 1100, 1500, 1780, 2000, 3000, 3840'
  assign image_height = section.settings.image.width | divided_by: section.settings.image.aspect_ratio
  assign fetch_priority = 'auto'
  if section.index == 1
    assign fetch_priority = 'high'
  endif
-%}

{{
  section.settings.image
  | image_url: width: 3840
  | image_tag:
  width: section.settings.image.width,
  height: image_height,
  widths: widths,
  fetchpriority: fetch_priority
}}

6. Converting requires extensive testing

For your pre-live checklist, make sure to:

  1. Upload the section file to your development theme.
  2. Use the theme customizer to include the section on a page.
  3. Test every setting, including text, images, URLs, and toggles.
  4. Review mobile and tablet responsive behavior.
  5. Inspect and validate HTML/CSS, correcting any mismatches.
  6. Default values must be set and visible to confirm the section renders without any interaction.

Found this helpful?

Share it with your network!

Ready to Convert HTML to Liquid?

Try our free HTML to Liquid converter and build your Shopify themes faster.

Try HTML2Liquid Now