
Building Shopify Storefronts with Hydrogen and Liquid
Table of contents
- What Is Liquid?
- How Liquid works
- Where Liquid lives
- When to use Liquid
- What Is Hydrogen?
- Why headless?
- How Hydrogen works
- Liquid vs Hydrogen: Which One Do You Use?
- Step-by-Step: Setting Up a Liquid Theme Project
- 1. Set up the Shopify CLI
- 2. Log in to your Shopify partner account
- 3. Pull down an existing theme or start from Dawn
- Clone the official Dawn starter theme
- Or pull from an existing store
- 4. Start the dev server
- 5. Customize templates and sections
- 6. Push changes to the store
- Step-by-Step: Setting Up a Hydrogen Project
- 1. Create a new Hydrogen app
- 2. Connect to the client's Shopify store
- 3. Start the dev server
- 4. Build your routes and components
- 5. Handle the cart
- 6. Deploy to Oxygen (Shopify's hosting) or Vercel
- What to Walk Through With Your Client
- 1. Access to the store
- 2. Shopify plan
- 3. Domain and DNS
- 4. Theme vs headless decision
- 5. Content management
- Shopify Metafields
- Setting up metafields
- Using metafields in Liquid
- Common metafield types
- Using metafields in Hydrogen
- Building a Custom Liquid Section from Scratch
- The file
- The structure
- What each part does
- Adding the section to a page
- Section vs snippet
- Final Thoughts
- Resources
If a client comes to you and says "I need a Shopify store", your first question should be:
How much control do they actually need?
Because depending on the answer, you might be writing Liquid templates inside the Shopify admin, or you might be spinning up a full React-based storefront with Hydrogen.
Both tools are part of the Shopify ecosystem. But they solve different problems and require very different workflows.
This post breaks both of them down โ what they are, how they work, and what the actual steps look like when building for a client.
What Is Liquid?
Liquid is Shopify's built-in templating language. It's been around since the beginning of Shopify and it's how the default theme system works.
Every standard Shopify theme โ Dawn, Debut, any theme from the Theme Store โ is built with Liquid.
If you've worked with Jinja, Handlebars, or any server-rendered template language, Liquid will feel familiar.
How Liquid works
Liquid uses a mix of objects, tags, and filters to render dynamic content inside HTML templates.
<!-- Output an object value -->
<h1>{{ product.title }}</h1>
<!-- Loop through items -->
{% for item in cart.items %}
<p>{{ item.title }} - {{ item.price | money }}</p>
{% endfor %}
<!-- Conditional logic -->
{% if product.available %}
<button>Add to Cart</button>
{% else %}
<p>Sold Out</p>
{% endif %}Shopify renders Liquid on the server and sends plain HTML to the browser. No client-side framework involved.
Where Liquid lives
Liquid templates live inside your Shopify theme, which you can edit directly in the Shopify admin under Online Store > Themes > Edit Code.
The theme file structure looks like this:
theme/
layout/
theme.liquid โ main wrapper for every page
templates/
index.liquid โ homepage
product.liquid โ product detail page
collection.liquid โ collection/category page
cart.liquid โ cart page
sections/
header.liquid
footer.liquid
snippets/
product-card.liquid โ reusable components
assets/
theme.css
theme.js
When to use Liquid
- The client wants a standard Shopify theme with some customization
- They need Shopify's built-in checkout (which is Liquid-based)
- The scope is mostly styling and content changes, not a custom frontend
- You want to stay inside the Shopify admin without setting up a separate codebase
Liquid is the right call for most standard Shopify builds. It's fast to set up, and Shopify manages hosting and infrastructure for you.
What Is Hydrogen?
Hydrogen is Shopify's React-based framework for building headless storefronts.
Headless means your frontend is completely decoupled from Shopify's backend. Shopify handles products, inventory, orders, and checkout โ but your frontend is a custom React app that pulls data via the Storefront API.
Hydrogen is built on top of Remix, so if you've used Remix before, it will feel familiar.
Why headless?
Standard Liquid themes have constraints. The design is tied to Shopify's theme structure. Interactions are limited unless you bolt on a lot of JavaScript. Performance can hit a ceiling.
Headless removes those constraints.
With Hydrogen, your storefront can look and behave like any modern React app โ full control over the UI, animations, routing, and performance optimizations.
How Hydrogen works
Hydrogen apps communicate with Shopify using GraphQL through the Storefront API. You write queries to fetch products, collections, cart data, and more.
// Example: fetching a product by handle
const PRODUCT_QUERY = `#graphql
query Product($handle: String!) {
product(handle: $handle) {
id
title
description
priceRange {
minVariantPrice {
amount
currencyCode
}
}
images(first: 5) {
nodes {
url
altText
}
}
}
}
`;Then in your Remix loader, you call the Storefront API:
export async function loader({ params, context }) {
const { storefront } = context;
const { product } = await storefront.query(PRODUCT_QUERY, {
variables: { handle: params.handle },
});
return { product };
}
export default function ProductPage() {
const { product } = useLoaderData();
return (
<div>
<h1>{product.title}</h1>
<p>{product.description}</p>
<p>{product.priceRange.minVariantPrice.amount}</p>
</div>
);
}Hydrogen handles the Storefront API connection, cart state, and session management for you. You focus on building the UI.
Liquid vs Hydrogen: Which One Do You Use?
| Liquid | Hydrogen | |
|---|---|---|
| Language | Liquid templates | React + Remix |
| Rendering | Server-rendered by Shopify | SSR/streaming via Remix |
| Hosting | Shopify handles it | You deploy it (Oxygen, Vercel, etc.) |
| Flexibility | Limited to theme structure | Full control |
| Setup time | Fast | Longer |
| Best for | Standard stores | Custom storefront experiences |
The honest answer: most client projects are fine with Liquid. If they need a fully custom UI or are building something beyond a standard store, that's when Hydrogen makes sense.
Step-by-Step: Setting Up a Liquid Theme Project
Here's the workflow for building a custom Shopify theme with Liquid.
1. Set up the Shopify CLI
Install the Shopify CLI:
npm install -g @shopify/cli @shopify/theme2. Log in to your Shopify partner account
shopify auth loginThis opens a browser and connects the CLI to your Shopify account.
3. Pull down an existing theme or start from Dawn
# Clone the official Dawn starter theme
shopify theme init my-client-theme
# Or pull from an existing store
shopify theme pull --store=your-client-store.myshopify.com4. Start the dev server
shopify theme dev --store=your-client-store.myshopify.comThis serves a live preview of your theme against your client's real store data. Changes to your local files hot-reload in the browser.
5. Customize templates and sections
Edit the Liquid files directly. Add sections for reusable page components, customize the product template, adjust the cart โ whatever the client needs.
<!-- sections/hero-banner.liquid -->
<section class="hero">
<h2>{{ section.settings.heading }}</h2>
<p>{{ section.settings.subheading }}</p>
<a href="{{ section.settings.button_url }}">
{{ section.settings.button_label }}
</a>
</section>
{% schema %}
{
"name": "Hero Banner",
"settings": [
{ "type": "text", "id": "heading", "label": "Heading" },
{ "type": "text", "id": "subheading", "label": "Subheading" },
{ "type": "text", "id": "button_label", "label": "Button Label" },
{ "type": "url", "id": "button_url", "label": "Button URL" }
]
}
{% endschema %}The {% schema %} block makes this section configurable inside the Shopify theme editor โ no code needed for the client to change copy.
6. Push changes to the store
shopify theme pushStep-by-Step: Setting Up a Hydrogen Project
Here's the workflow for a headless Hydrogen storefront.
1. Create a new Hydrogen app
npm create @shopify/hydrogen@latestThe CLI walks you through the setup and scaffolds a Remix-based app with the Storefront API already wired up.
2. Connect to the client's Shopify store
In your .env file:
PUBLIC_STORE_DOMAIN=your-client-store.myshopify.com
PUBLIC_STOREFRONT_API_TOKEN=your_storefront_api_tokenTo get the Storefront API token:
- Go to the Shopify admin
- Settings > Apps and sales channels > Develop apps
- Create a new app
- Under API credentials, generate a Storefront API access token
- Make sure to enable the scopes you need (products, cart, orders, etc.)
3. Start the dev server
npm run devYour Hydrogen app runs locally at http://localhost:3000 and pulls live data from the client's Shopify store.
4. Build your routes and components
Hydrogen follows Remix's file-based routing inside app/routes/.
app/
routes/
_index.jsx โ homepage
products.$handle.jsx โ product detail page
collections.$handle.jsx
cart.jsx
components/
ProductCard.jsx
Header.jsx
Footer.jsx
Each route has a loader function for data fetching and a default export for the UI component.
5. Handle the cart
Hydrogen has a built-in CartForm component and cart utilities that handle Shopify's cart API:
import { CartForm } from '@shopify/hydrogen';
export function AddToCartButton({ variantId }) {
return (
<CartForm
route="/cart"
action={CartForm.ACTIONS.LinesAdd}
inputs={{ lines: [{ merchandiseId: variantId, quantity: 1 }] }}
>
<button type="submit">Add to Cart</button>
</CartForm>
);
}6. Deploy to Oxygen (Shopify's hosting) or Vercel
Shopify's own hosting for Hydrogen apps is called Oxygen. It's the recommended option.
shopify hydrogen deployOr if you're deploying to Vercel:
vercelWhat to Walk Through With Your Client
Whether you go Liquid or Hydrogen, there are a few things you need to nail down with the client before you write a line of code.
1. Access to the store
You'll need to be added as a staff member or collaborator on their Shopify account.
- Staff: full admin access
- Collaborator: limited access โ you request it through the Shopify Partner dashboard
For Hydrogen, they also need to enable Develop Apps so you can generate a Storefront API token.
2. Shopify plan
Some features (like custom checkout extensibility) require specific Shopify plans. Confirm what plan they're on early so you don't hit a wall mid-project.
3. Domain and DNS
If you're deploying a Hydrogen app, the client's domain needs to point to your hosting. Walk them through or handle the DNS changes yourself โ don't leave this for the last day.
4. Theme vs headless decision
Have an honest conversation about what they actually need. A custom Liquid theme handles 90% of use cases and is faster to build and maintain. Hydrogen is the right call when they genuinely need a custom frontend experience.
5. Content management
With Liquid, the client edits content through the Shopify theme editor. With Hydrogen, you'll need to decide how they manage content โ Shopify metafields, a CMS like Contentful or Sanity, or static content in the codebase.
Shopify Metafields
Metafields let you attach custom data to almost anything in Shopify โ products, collections, variants, customers, orders, pages.
Out of the box, a product has a title, description, price, and images. But what if you need to store a size guide, an ingredient list, a YouTube embed, or a care instructions label? That's where metafields come in.
Setting up metafields
Go to Settings > Custom data in the Shopify admin. From there you can create metafield definitions for any resource.
For example, adding a "Care Instructions" field to products:
- Go to Settings > Custom data > Products
- Click Add definition
- Set the name:
Care Instructions - Set the namespace and key:
custom.care_instructions - Choose the type:
Single line textorMulti-line text - Save
Now every product has that field available to fill in from the product edit page.
Using metafields in Liquid
Once defined, you can access metafields in your templates:
<!-- On a product page -->
{% if product.metafields.custom.care_instructions %}
<div class="care-instructions">
<h3>Care Instructions</h3>
<p>{{ product.metafields.custom.care_instructions.value }}</p>
</div>
{% endif %}The pattern is always resource.metafields.namespace.key.value.
Common metafield types
| Type | Use case |
|---|---|
| Single line text | Short labels, SKUs, taglines |
| Multi-line text | Long descriptions, instructions |
| Rich text | Formatted content with headings and lists |
| Integer / Decimal | Numeric specs (weight, dimensions) |
| True/False | Feature flags (is_new, on_sale) |
| File | PDFs, additional images |
| URL | External links, video embeds |
| Reference | Link to another product, collection, or page |
Using metafields in Hydrogen
In Hydrogen you query metafields through the Storefront API. You need to explicitly request them in your GraphQL query:
const PRODUCT_QUERY = `#graphql
query Product($handle: String!) {
product(handle: $handle) {
id
title
careInstructions: metafield(namespace: "custom", key: "care_instructions") {
value
}
}
}
`;Then in your component:
export default function ProductPage() {
const { product } = useLoaderData();
return (
<div>
<h1>{product.title}</h1>
{product.careInstructions && (
<div>
<h3>Care Instructions</h3>
<p>{product.careInstructions.value}</p>
</div>
)}
</div>
);
}Metafields are one of the most powerful features in Shopify for handling client-specific data needs without hacking the product description field.
Building a Custom Liquid Section from Scratch
Sections are the building blocks of a Shopify theme. They're Liquid files that can be added to pages through the theme editor, and they come with a {% schema %} block that makes them configurable without touching code.
Here's how to build one from scratch.
The file
Create a new file in sections/ โ for example sections/testimonials.liquid.
The structure
Every section has two parts: the HTML/Liquid markup and the schema block at the bottom.
<!-- sections/testimonials.liquid -->
<section class="testimonials" style="background: {{ section.settings.bg_color }}">
<div class="testimonials__container">
{% if section.settings.heading != blank %}
<h2 class="testimonials__heading">{{ section.settings.heading }}</h2>
{% endif %}
<div class="testimonials__grid">
{% for block in section.blocks %}
<div class="testimonial-card" {{ block.shopify_attributes }}>
<p class="testimonial-card__quote">"{{ block.settings.quote }}"</p>
<p class="testimonial-card__author">โ {{ block.settings.author }}</p>
{% if block.settings.role != blank %}
<p class="testimonial-card__role">{{ block.settings.role }}</p>
{% endif %}
</div>
{% endfor %}
</div>
</div>
</section>
{% schema %}
{
"name": "Testimonials",
"tag": "section",
"settings": [
{
"type": "text",
"id": "heading",
"label": "Heading",
"default": "What our customers say"
},
{
"type": "color",
"id": "bg_color",
"label": "Background color",
"default": "#ffffff"
}
],
"blocks": [
{
"type": "testimonial",
"name": "Testimonial",
"settings": [
{
"type": "textarea",
"id": "quote",
"label": "Quote"
},
{
"type": "text",
"id": "author",
"label": "Author name"
},
{
"type": "text",
"id": "role",
"label": "Role or company"
}
]
}
],
"presets": [
{
"name": "Testimonials",
"blocks": [
{ "type": "testimonial" },
{ "type": "testimonial" },
{ "type": "testimonial" }
]
}
]
}
{% endschema %}What each part does
section.settings โ values configured at the section level. Things like a heading, background color, or layout option that apply to the whole section.
blocks โ repeatable items inside the section. Each block has its own settings. In the testimonials example, each testimonial card is a block โ the client can add, remove, and reorder them in the theme editor without touching code.
{{ block.shopify_attributes }} โ always include this on block elements. It enables drag-to-reorder in the theme editor.
presets โ defines what the section looks like when first added to a page. Setting default blocks means the client sees something useful immediately instead of an empty section.
Adding the section to a page
Once the file exists, the section shows up in the theme editor automatically under Add section. The client can drop it onto any page and configure it through the sidebar โ no code required on their end.
Section vs snippet
A quick distinction that trips people up:
- Sections can be added and configured through the theme editor. Use them for page-level components.
- Snippets are reusable partials you include in templates or sections with
{% render 'snippet-name' %}. Use them for smaller, reusable pieces of markup like a product card or an icon.
Final Thoughts
Both Liquid and Hydrogen are solid tools. The choice comes down to scope and flexibility.
-
If the client needs a polished Shopify store and the standard theme structure is enough โ go with Liquid. It's fast to build, easy to maintain, and the client can manage it themselves.
-
If they need a fully custom frontend, complex UI interactions, or integration with an existing React codebase โ go with Hydrogen. More setup upfront, but full control.
Understanding both puts you in a much stronger position when a Shopify project lands in your lap.
Resources
- Shopify Liquid Docs
- Hydrogen Docs
- Remix Docs
- Shopify Storefront API
- Shopify Metafields Docs
- Dawn Theme (GitHub)
If you have questions about Shopify builds or want to talk through a client project, find me on LinkedIn.

Discussion
Comments
Loading comments...