Skip to main content
1:1 mock interviews with Sumit, scored on a real hiring rubric.Book a slot →

Shopify Frontend Development Guide: Liquid, Themes and Hydrogen

Learn Shopify frontend development step by step: CLI setup, theme architecture, Liquid, sections, theme blocks, the Cart API, performance, SEO and Hydrogen.

jiocoder TeamUpdated Oct 7, 202613 min readShopify
Shopify Frontend Development Guide: Liquid, Themes and Hydrogen

Shopify frontend development is the work of building what shoppers see and use in a Shopify store: product pages, collections, the cart and every interaction in between. This guide walks you through both ways to do it, Liquid themes and headless storefronts with Hydrogen, with setup steps, real code and the best practices that keep a store fast and search-friendly.

Liquid template code for a product card rendering into a Shopify storefront product card with title, price and Add to cart button
What you will learn

How Shopify themes are structured, how to write Liquid, how sections and theme blocks make a store editable, how to add an interactive "Add to cart" button, how to keep your theme fast and SEO-friendly, and when to choose Hydrogen instead of a theme.

Two ways to build a Shopify frontend#

Every Shopify storefront is built in one of two ways. Choosing the right one early saves a lot of rework later.

  • Liquid themes (Online Store): Shopify hosts and renders your pages on the server using Liquid, its templating language. Merchants customize the store visually in the theme editor. This is how most Shopify stores are built.
  • Headless with Hydrogen: you build a custom React app that fetches store data from the Storefront API (GraphQL). Hydrogen is Shopify's React framework for this, and it is commonly deployed to Oxygen, Shopify's hosting for Hydrogen apps.
QuestionLiquid themeHydrogen (headless)
Main languageLiquid, HTML, CSS, JavaScriptReact, TypeScript, GraphQL
Who renders pagesShopify's serversYour app (on Oxygen or another host)
Merchant editingBuilt in, through the theme editorNeeds a CMS or custom tooling
Apps from the App StoreMost work out of the boxMany need custom integration
Best forMost stores, fast launches, agency workHighly custom experiences, large brands with dev teams
Tip

If you are new to Shopify, start with themes. Most Shopify frontend jobs are theme work, and everything you learn about Liquid, sections and the theme editor applies directly to real client stores.

Set up your development environment#

You need three things: a store to develop on, Shopify CLI, and a code editor.

1. Get a development store#

Create a free Shopify Partner account, then create a development store from the Partner dashboard. Development stores are free and meant for building and testing themes and apps.

2. Install Shopify CLI#

Shopify CLI is the command-line tool for theme and Hydrogen development. It needs Node.js 22.12 or higher and Git 2.28 or higher.

Bash
# Install Shopify CLI globally
npm install -g @shopify/cli@latest

# Check that it works
shopify version

3. Start a theme and preview it#

Bash
# Create a new theme from Shopify's starter theme
shopify theme init my-theme
cd my-theme

# Preview it on your dev store with hot reload
shopify theme dev --store your-store.myshopify.com

shopify theme dev uploads your theme as a development theme and gives you a local preview URL (by default http://127.0.0.1:9292). Edit a file, save, and the preview updates instantly.

Shopify CLI theme commands you will use most#

CommandWhat it does
shopify theme initCreates a new theme from a starter Git repository
shopify theme devRuns a live preview with hot reload
shopify theme pullDownloads a theme from your store
shopify theme pushUploads your local files to a theme on the store
shopify theme checkLints your theme for errors and Liquid best practices
shopify theme shareUploads the theme as a new unpublished theme and gives you a preview link
shopify theme publishMakes an unpublished theme the live theme
shopify theme packageZips the theme for upload
shopify theme profileProfiles Liquid rendering on a page to find slow code
shopify theme consoleOpens a Liquid REPL to try out code
Warning

shopify theme push can overwrite files on a theme. Never push directly to the live theme while you are developing. Use theme dev or push to an unpublished copy, and keep your theme in Git.

Shopify theme architecture#

A Shopify theme has a fixed folder structure. Other subfolders are not supported, so every file has a specific home.

Shopify theme folder structure: layout, templates, sections, blocks, snippets, assets, config and locales folders with what each one holds
Bash
my-theme/
├── assets/      # CSS, JavaScript, images, fonts
├── blocks/      # Theme blocks: reusable pieces placed inside sections
├── config/      # settings_schema.json and settings_data.json
├── layout/      # theme.liquid: the page wrapper (required)
├── locales/     # Translation files
├── sections/    # Sections and section groups (header, footer)
├── snippets/    # Reusable Liquid partials
└── templates/   # One template per page type (product, collection...)
    ├── customers/
    └── metaobject/

What each part does#

  • layout/theme.liquid: the only required file. It wraps every page and holds what repeats everywhere: the <head>, header and footer.
  • templates/: decide what each page type shows. JSON templates (like product.json) just list which sections appear and in what order, so merchants can rearrange them. Liquid templates contain code directly and are less flexible.
  • sections/: reusable, customizable modules such as a hero banner or product grid. Merchants add, remove and reorder them in the theme editor.
  • Section groups: JSON files in sections/ that let merchants edit areas of the layout, such as the header and footer.
  • blocks/: theme blocks, small building blocks (text, button, image) that can be placed inside many different sections and even nested inside each other.
  • snippets/: reusable chunks of Liquid you render with {% render %}. Merchants never see them.
  • config/: settings_schema.json defines theme-wide settings like colors and fonts. settings_data.json stores the values merchants pick.
  • assets/: static files. A file like theme.css.liquid can also use Liquid to read theme settings.

Liquid basics: objects, tags and filters#

Liquid is the templating language that turns store data into HTML. It has three building blocks.

Liquid syntax in 3 parts: objects with double curly braces print values, tags with curly brace percent add logic, filters with a pipe change output

Objects: output data#

Double curly braces print a value from the store, such as the current product.

LIQUID
<h1>{{ product.title }}</h1>
<p>{{ product.vendor }}</p>

Tags: logic and loops#

Curly braces with percent signs add logic. They produce no output by themselves.

LIQUID
{% if product.available %}
  <button type="submit">Add to cart</button>
{% else %}
  <button disabled>Sold out</button>
{% endif %}

<ul>
  {% for variant in product.variants %}
    <li>{{ variant.title }}</li>
  {% endfor %}
</ul>

Filters: transform values#

Filters come after a pipe | and change how a value is shown. You can chain several filters.

LIQUID
{{ product.price | money }}          <!-- Rs. 999.00 -->
{{ product.title | upcase }}         <!-- CLASSIC COTTON TEE -->
{{ product.description | strip_html | truncate: 120 }}
Tip

Prices in Liquid are stored in the smallest currency unit (cents or paise). Always display them with the money filter instead of formatting them yourself, so the store's currency settings are respected.

Sections and JSON templates#

Sections are what make a theme editable without code. Each section file has two parts: the markup and a {% schema %} block that tells the theme editor which settings to show.

LIQUID
{%- comment -%} sections/featured-product.liquid {%- endcomment -%}
{%- assign product = section.settings.product -%}

<section class="featured-product">
  <h2>{{ section.settings.heading }}</h2>

  {%- if product != blank -%}
    {{ product | image_url: width: 800 | image_tag: loading: 'lazy', alt: product.title }}
    <h3>{{ product.title }}</h3>
    <p>{{ product.price | money }}</p>
    <a href="{{ product.url }}">View product</a>
  {%- else -%}
    <p>Choose a product in the theme editor.</p>
  {%- endif -%}
</section>

{% schema %}
{
  "name": "Featured product",
  "settings": [
    { "type": "text", "id": "heading", "label": "Heading", "default": "Bestseller" },
    { "type": "product", "id": "product", "label": "Product" }
  ],
  "presets": [{ "name": "Featured product" }]
}
{% endschema %}

The presets entry makes the section appear in the theme editor's "Add section" menu. The product setting type gives merchants a product picker, so they choose what to feature without touching code.

How a JSON template uses sections#

A JSON template lists the sections on a page and their order. Merchants change this file through the theme editor, not by hand.

JSON
{
  "sections": {
    "hero": { "type": "featured-product", "settings": { "heading": "Bestseller" } }
  },
  "order": ["hero"]
}

Theme blocks: the modern way to build#

Theme blocks are Liquid files in the blocks/ folder. Unlike blocks defined inside a single section, they can be reused across many sections and nested inside each other. Shopify's Horizon theme family, launched in 2025, is built around them.

How a Shopify page is built: a product template holds sections, each section holds blocks, and a group block holds nested theme blocks

Create a theme block#

LIQUID
{%- comment -%} blocks/badge.liquid {%- endcomment -%}
<span class="badge badge--{{ block.settings.style }}" {{ block.shopify_attributes }}>
  {{ block.settings.text }}
</span>

{% schema %}
{
  "name": "Badge",
  "settings": [
    { "type": "text", "id": "text", "label": "Text", "default": "New" },
    {
      "type": "select", "id": "style", "label": "Style", "default": "primary",
      "options": [
        { "value": "primary", "label": "Primary" },
        { "value": "sale", "label": "Sale" }
      ]
    }
  ],
  "presets": [{ "name": "Badge" }]
}
{% endschema %}

Let a section accept theme blocks#

A section renders its blocks with {% content_for 'blocks' %}. Adding "@theme" to the schema allows any theme block, and "@app" allows app blocks from installed apps.

LIQUID
{%- comment -%} sections/custom-content.liquid {%- endcomment -%}
<div class="custom-content">
  {% content_for 'blocks' %}
</div>

{% schema %}
{
  "name": "Custom content",
  "blocks": [{ "type": "@theme" }, { "type": "@app" }],
  "presets": [{ "name": "Custom content" }]
}
{% endschema %}
Note

{{ block.shopify_attributes }} adds attributes the theme editor uses to select and highlight the block. Always include it on the block's outer element.

Build an interactive "Add to cart" button#

Liquid renders HTML on the server. For interactivity, such as adding to the cart without a page reload, you add JavaScript. Shopify themes expose the Cart AJAX API for this, and a small web component keeps the code self-contained.

Step 1: The markup#

LIQUID
{%- comment -%} snippets/add-to-cart.liquid {%- endcomment -%}
<add-to-cart data-variant-id="{{ product.selected_or_first_available_variant.id }}">
  <button type="button" {% unless product.available %}disabled{% endunless %}>
    {% if product.available %}Add to cart{% else %}Sold out{% endif %}
  </button>
  <p class="add-to-cart__status" role="status" aria-live="polite"></p>
</add-to-cart>

Step 2: The JavaScript#

JavaScript
// assets/add-to-cart.js
class AddToCart extends HTMLElement {
  connectedCallback() {
    this.button = this.querySelector('button');
    this.status = this.querySelector('[role="status"]');
    this.button.addEventListener('click', () => this.add());
  }

  async add() {
    this.button.disabled = true;
    this.status.textContent = 'Adding...';

    try {
      const res = await fetch(window.Shopify.routes.root + 'cart/add.js', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          items: [{ id: Number(this.dataset.variantId), quantity: 1 }],
        }),
      });

      if (!res.ok) {
        const error = await res.json();
        throw new Error(error.description || 'Could not add to cart');
      }
      this.status.textContent = 'Added to cart';
    } catch (err) {
      this.status.textContent = err.message;
    } finally {
      this.button.disabled = false;
    }
  }
}

customElements.define('add-to-cart', AddToCart);

Step 3: Load the script#

LIQUID
<script src="{{ 'add-to-cart.js' | asset_url }}" defer></script>
{% render 'add-to-cart', product: product %}

Why this approach works well:

  • No framework needed: web components are built into the browser, so you ship very little JavaScript.
  • Accessible: the role="status" region announces the result to screen readers.
  • Locale-safe: window.Shopify.routes.root keeps the URL correct on translated storefronts like /en-in/.

Performance and SEO best practices#

A fast store ranks better and sells more. These habits make the biggest difference in Shopify themes.

Serve responsive, lazy-loaded images#

Use image_url and image_tag so Shopify's CDN serves the right size for each screen. Lazy-load images below the fold, but never the main hero or product image.

LIQUID
{{ product.featured_image
  | image_url: width: 1200
  | image_tag:
      widths: '400, 800, 1200',
      sizes: '(min-width: 990px) 50vw, 100vw',
      loading: 'lazy' }}

When you pass an image object, image_tag uses the image's own alt text automatically, so the merchant's alt text from the admin is kept.

Keep JavaScript small and deferred#

  • Load scripts with defer so they don't block rendering.
  • Load a script only on the pages and sections that need it.
  • Prefer native HTML and CSS (details/summary, CSS scroll-snap) over JavaScript libraries.
  • Audit installed apps: each one can add its own scripts to every page.

Get the SEO basics right in theme.liquid#

LIQUID
<head>
  <title>{{ page_title }}{% unless page_title contains shop.name %} | {{ shop.name }}{% endunless %}</title>
  {%- if page_description -%}
    <meta name="description" content="{{ page_description | escape }}">
  {%- endif -%}
  <link rel="canonical" href="{{ canonical_url }}">
  {{ content_for_header }}
</head>
  • Structured data: add product rich results with {{ product | structured_data }} inside a <script type="application/ld+json"> tag on product pages.
  • One <h1> per page: usually the product, collection or article title.
  • Alt text: always output the merchant's image alt text, with the product title as a fallback.
  • Lint before shipping: run shopify theme check to catch errors, and shopify theme profile to find slow Liquid.
Warning

Never remove {{ content_for_header }} from theme.liquid. Shopify uses it to load analytics, apps and checkout features, and the store will break without it.

Going headless with Hydrogen#

Hydrogen is Shopify's framework for building custom React storefronts. It is built on React Router 7 and gives you ready-made helpers for the cart, SEO, caching and Storefront API queries.

Create a Hydrogen project#

Bash
# Scaffold a new Hydrogen storefront
npm create @shopify/hydrogen@latest -- --quickstart

# Start the dev server (http://localhost:3000)
cd my-storefront
npm run dev

A new project uses demo data from mock.shop. To show your own products, link it to your store with npx shopify hydrogen link and pull its environment variables with npx shopify hydrogen env pull.

Fetch a product with the Storefront API#

In Hydrogen, each route can have a loader that runs on the server and queries the Storefront API with GraphQL.

TSX
// app/routes/products.$handle.tsx
import { useLoaderData } from 'react-router';
import type { LoaderFunctionArgs } from 'react-router';

export async function loader({ params, context }: LoaderFunctionArgs) {
  const { product } = await context.storefront.query(PRODUCT_QUERY, {
    variables: { handle: params.handle },
  });
  if (!product) throw new Response('Not found', { status: 404 });
  return { product };
}

export default function Product() {
  const { product } = useLoaderData<typeof loader>();
  return (
    <main>
      <h1>{product.title}</h1>
      <div dangerouslySetInnerHTML={{ __html: product.descriptionHtml }} />
    </main>
  );
}

const PRODUCT_QUERY = `#graphql
  query Product($handle: String!) {
    product(handle: $handle) {
      id
      title
      descriptionHtml
    }
  }
`;

When to choose Hydrogen#

  • Choose Hydrogen when you need a fully custom experience, complex content from multiple systems, or your team already works in React.
  • Stay with a theme when merchants need to edit pages themselves, you rely on many App Store apps, or you need to launch quickly.
Tip

New to React? Strengthen your fundamentals first with our React interview questions and JavaScript interview questions guides. Hydrogen builds directly on both.

Common mistakes to avoid#

  • Hard-coding content: if a merchant would ever want to change it, make it a section or block setting.
  • Editing core files of a theme that receives updates: put customizations in your own sections, blocks and assets so updates don't overwrite them.
  • Formatting prices by hand: use the money filters.
  • Lazy-loading the main image: it delays the largest content on the page and hurts Core Web Vitals.
  • Skipping theme check: it catches broken references, missing translations and performance problems before your client does.

Frequently asked questions#

What language is used for Shopify frontend development?#

Shopify themes use Liquid together with HTML, CSS and JavaScript. Headless storefronts built with Hydrogen use React, usually with TypeScript, and GraphQL for the Storefront API.

Do I need to know React to work with Shopify?#

No. Most Shopify frontend work is theme development, which needs Liquid, HTML, CSS and JavaScript. React is only needed for Hydrogen and for some app development.

What is the difference between sections and blocks?#

A section is a full-width module of a page, like a banner or product grid. A block is a smaller piece inside a section, like a heading, button or badge. Theme blocks can be reused across sections and nested.

Is Hydrogen better than a Shopify theme?#

Not by default. Hydrogen gives more control but needs more development and maintenance. A well-built theme is the better choice for most stores.

How do I test a Shopify theme without affecting the live store?#

Run shopify theme dev to preview changes on a development theme, or use shopify theme share to upload an unpublished copy and share a preview link.

Further reading#

Key takeaways#

  • Shopify frontends are built either as Liquid themes or as headless Hydrogen apps. Most stores should use themes.
  • Install Shopify CLI and use shopify theme dev for a live, hot-reloading preview on a development store.
  • Liquid has three parts: objects {{ }}, tags {% %} and filters |.
  • Sections with a schema and theme blocks make every part of the store editable without code.
  • Add interactivity with small web components and the Cart AJAX API.
  • Keep stores fast with responsive images, deferred JavaScript and shopify theme check, and get SEO right with titles, descriptions, canonical URLs and structured data.