Shopify Liquid Tutorial: How to Get Started with Liquid
Shopify Liquid Tutorial is the perfect starting point for anyone who wants to understand Shopify theme development and build more customized online stores. Whether you are a beginner learning Shopify development or an experienced web developer looking to expand your skills, understanding Liquid will help you customize Shopify themes, create dynamic content, and build unique storefront experiences.
Shopify Liquid is an open-source template language developed by Shopify. It acts as the connection between your Shopify store’s data and the HTML displayed to customers. With Liquid, you can dynamically display product information, collection details, prices, customer data, blog posts, and other store content without manually creating separate pages for every product or collection.
In this complete Shopify Liquid tutorial, we’ll explain the fundamentals of Liquid, how its syntax works, and how you can start using it in Shopify themes. You’ll learn about Liquid objects, tags, filters, variables, conditional statements, loops, and other essential concepts. We’ll also explore practical examples that demonstrate how Liquid works in real Shopify theme development projects.
Whether your goal is to customize an existing Shopify theme, create custom product templates, modify homepage sections, or develop a completely custom Shopify theme, this guide will give you a solid foundation.
What Is Shopify Liquid?
Shopify Liquid is a template language that allows developers to display dynamic store information inside Shopify themes. Instead of writing separate HTML pages for individual products, Liquid makes it possible to create reusable templates that automatically display the correct information based on the page being viewed.
For example, imagine an online store with hundreds of products. Each product has a different title, price, description, image, and availability status. Creating individual HTML pages for every product would be time-consuming and difficult to maintain.
Liquid solves this problem by using dynamic objects. You can create one product template and use Liquid variables to display the appropriate product information automatically.
For example:
<h1>{{ product.title }}</h1>
<p>{{ product.price | money }}</p>
<div>
{{ product.description }}
</div>
This simple code displays the current product’s title, formatted price, and description. When a customer visits another product page, Shopify automatically provides the relevant product information.
Liquid works alongside HTML, CSS, and JavaScript in Shopify themes. It handles dynamic content and template logic, while HTML structures the page and CSS controls its appearance.
Why Is Liquid Important for Shopify Theme Development?
Liquid is an essential skill for developers who want greater control over Shopify themes. Although Shopify provides a visual Theme Editor for basic customization, many advanced design and functionality changes require working directly with theme code.
Learning Liquid allows you to:
- Customize product pages and collection templates.
- Display dynamic product and collection information.
- Create custom homepage sections.
- Build reusable snippets and theme components.
- Add conditional content based on product availability.
- Customize navigation menus and website layouts.
- Work with metafields and custom product information.
- Develop advanced Shopify theme features.
- Fix theme-related bugs and functionality issues.
- Create more flexible and personalized shopping experiences.
For Shopify developers, understanding Liquid makes it easier to work with existing themes and build custom solutions based on specific business requirements.
Understanding the Three Main Components of Liquid
Before writing Liquid code, you should understand its three main components: objects, tags, and filters. These are the building blocks of almost every Shopify Liquid implementation.
1. Liquid Objects
Objects contain store information that can be displayed on a Shopify storefront. They are written using double curly braces.
For example:
{{ product.title }}
{{ product.price }}
{{ shop.name }}
{{ collection.title }}
These objects retrieve information from the Shopify store.
Some commonly used Shopify Liquid objects include:
product– Contains information about the current product.collection– Provides collection information.cart– Contains shopping cart data.customer– Provides available customer information.shop– Contains general store information.page– Provides information about the current page.blog– Contains blog information.article– Provides individual blog article information.
You can also access object properties using dot notation. For example, product.title retrieves a product’s title, while product.vendor retrieves its vendor name.
2. Liquid Tags
Tags control the logic and functionality of Liquid templates. Unlike objects, tags are written using curly braces and percentage signs.
For example:
{% if product.available %}
<p>In Stock</p>
{% else %}
<p>Sold Out</p>
{% endif %}
This code checks whether a product is available. If it is available, customers see the In Stock message. Otherwise, the Sold Out message appears.
Common Liquid tags include:
if– Executes code when a condition is true.unless– Executes code when a condition is false.for– Repeats code for multiple items.case– Checks different possible values.assign– Creates variables.capture– Stores generated content in a variable.render– Loads a reusable snippet.comment– Adds comments that are not displayed on the storefront.
3. Liquid Filters
Filters modify the output of objects or variables. They are separated from the original value using the pipe symbol (|).
For example:
{{ product.title | upcase }}
This displays the product title in uppercase letters.
Another example:
{{ product.description | strip_html }}
This removes HTML tags from the product description.
Other useful Liquid filters include:
capitalize– Capitalizes the first character.downcase– Converts text to lowercase.upcase– Converts text to uppercase.money– Formats a price as currency.date– Formats date values.default– Provides a fallback value.escape– Escapes HTML characters.truncate– Limits the length of text.append– Adds text to the end of a string.replace– Replaces specific text.
You can combine multiple filters to transform output according to your requirements.
How to Create Variables in Shopify Liquid
Variables allow developers to store values and reuse them throughout a Liquid template. They are especially useful when you need to perform calculations, organize information, or simplify repeated code.
The assign tag is commonly used to create variables.
Example:
{% assign store_message = "Welcome to our store!" %}
<p>{{ store_message }}</p>
The variable store_message stores the text and displays it wherever you use the variable.
You can also assign numerical values:
{% assign product_count = 10 %}
<p>Total Products: {{ product_count }}</p>
Another useful variable tag is capture. It allows you to capture a block of generated text and save it as a variable.
{% capture welcome_message %}
Welcome to {{ shop.name }}!
{% endcapture %}
<p>{{ welcome_message }}</p>
Understanding variables is important because they help keep Liquid code organized, reusable, and easier to maintain.
Using Conditional Statements in Shopify Liquid
Conditional statements allow you to display different content depending on specific conditions. They are commonly used for product availability, discounts, customer information, and promotional messages.
The if, elsif, else, and unless tags are useful for handling conditions.
Example:
{% if product.available %}
<button>Add to Cart</button>
{% else %}
<button disabled>Sold Out</button>
{% endif %}
This example displays an Add to Cart button when a product is available. If the product is unavailable, it displays a disabled Sold Out button.
You can also check multiple conditions:
{% if product.price > 5000 %}
<p>Premium Product</p>
{% elsif product.price > 2000 %}
<p>Popular Product</p>
{% else %}
<p>Budget Friendly Product</p>
{% endif %}
Conditional statements are particularly helpful when building custom product badges, promotional labels, and dynamic content blocks.
Working with Loops in Shopify Liquid
Loops allow developers to repeat a block of code for multiple items. They are frequently used to display products, collections, navigation links, and other lists of information.
The for tag is the most commonly used loop in Liquid.
Example:
{% for product in collection.products %}
<h3>{{ product.title }}</h3>
<p>{{ product.price | money }}</p>
{% endfor %}
This code loops through the products in a collection and displays each product’s title and price.
You can also limit the number of products displayed:
{% for product in collection.products limit: 4 %}
<h3>{{ product.title }}</h3>
{% endfor %}
This example displays only four products.
Loops are useful for building product grids, featured collections, navigation menus, and other dynamic website components.
How to Use Liquid Filters in Real Shopify Projects
Liquid filters help developers format and modify data before displaying it on the storefront. They are especially useful when working with product information, prices, images, and text.
For example, you can display a product price using the money filter:
{{ product.price | money }}
You can also create a shortened product description:
{{ product.description | strip_html | truncate: 120 }}
This removes HTML tags and limits the displayed description to 120 characters.
Another example is providing fallback content:
{{ product.vendor | default: "Our Store" }}
If the vendor value is blank or unavailable, the default text will be displayed.
Filters make it easier to format information without creating complicated additional logic.
Understanding Shopify Liquid Templates
Shopify themes use templates to control how different pages are displayed. Liquid helps these templates retrieve the correct store information and generate dynamic content.
Common Shopify template types include:
- Product templates – Display individual product information.
- Collection templates – Display products belonging to a collection.
- Page templates – Display custom store pages.
- Blog templates – Display blog listings.
- Article templates – Display individual blog posts.
- Cart templates – Display shopping cart information.
- Search templates – Display search results.
Modern Shopify themes use JSON templates to define page layouts and connect sections. Liquid files are used to create the dynamic content and functionality within those sections.
Understanding how templates work is important when customizing an existing Shopify theme or developing a new one.
How to Create Your First Shopify Liquid Section
Sections are reusable and customizable components that can be added to Shopify theme pages. They are particularly important because merchants can manage many section settings through Shopify’s Theme Editor.
For example, you can create a custom announcement section that displays a promotional message.
Create a new file inside your theme’s sections folder called custom-announcement.liquid.
Add the following code:
<div class="custom-announcement">
<p>{{ section.settings.text }}</p>
</div>
{% schema %}
{
"name": "Custom Announcement",
"settings": [
{
"type": "text",
"id": "text",
"label": "Announcement Text",
"default": "Free Shipping on All Orders"
}
],
"presets": [
{
"name": "Custom Announcement"
}
]
}
{% endschema %}
This section includes a customizable text setting. Once the section is available in the theme, you can add it through the Theme Editor and update its announcement message without editing the code again.
You can also add CSS to customize its colors, spacing, font size, and alignment.
Learning how to build sections is one of the most useful skills for Shopify theme developers.
Understanding Shopify Snippets and the Render Tag
Snippets are reusable pieces of Liquid code stored inside the snippets folder of a Shopify theme. They help developers avoid repeating the same code in multiple templates or sections.
For example, you can create a snippet for displaying a product title.
Create a file named custom-product-title.liquid inside the snippets folder.
Add:
<h2 class="custom-product-title">
{{ product.title }}
</h2>
You can then use the snippet inside another Liquid file with the render tag:
{% render 'custom-product-title' %}
You can also pass variables into snippets:
{% render 'custom-product-title', product: product %}
Using snippets makes your theme code more organized and easier to maintain. It is particularly useful when building reusable product cards, badges, buttons, and other common theme components.
How to Customize Shopify Product Pages with Liquid
Product pages are among the most important parts of an eCommerce website. Shopify Liquid allows developers to customize how product information is displayed and how different elements behave.
For example, you can display a product’s title, price, vendor, and availability using Liquid.
<h1>{{ product.title }}</h1>
<p>Price: {{ product.price | money }}</p>
<p>Brand: {{ product.vendor }}</p>
{% if product.available %}
<span>Available</span>
{% else %}
<span>Currently Sold Out</span>
{% endif %}
You can also work with product images, variants, descriptions, tags, and metafields to create more informative product pages.
For advanced customization, developers can combine Liquid with HTML, CSS, and JavaScript to build custom layouts, product information tabs, promotional labels, and additional product features.
Working with Shopify Metafields and Liquid
Shopify metafields allow merchants to store additional information about products, collections, customers, and other store resources.
For example, an electronics store may want to display additional product specifications such as battery capacity, warranty information, material, or technical details.
After creating and assigning a metafield definition in Shopify Admin, you can access its value through Liquid.
Example:
{% if product.metafields.custom.warranty %}
<p>
Warranty:
{{ product.metafields.custom.warranty.value }}
</p>
{% endif %}
This example checks whether the product has a warranty metafield before displaying its value.
Metafields are useful for building customized product information sections without adding unnecessary content to the main product description.
How to Debug Shopify Liquid Code
Errors are a normal part of learning Shopify Liquid. Sometimes a missing closing tag, incorrect variable name, or invalid object reference can prevent a theme component from working correctly.
Here are some practical debugging tips:
- Check that every opening Liquid tag has its corresponding closing tag.
- Verify object names and property references.
- Check the spelling of variable names.
- Review conditional statements and loop logic.
- Make sure filters are used with the correct syntax.
- Test changes on a duplicate theme before publishing.
- Use Shopify’s theme development tools to identify errors.
You can also use the json filter to inspect available object data during development:
{{ product | json }}
Be careful not to expose private customer or store information in public storefront output. Remove temporary debugging code before publishing your theme.
Best Practices for Writing Clean Shopify Liquid Code
Writing working Liquid code is important, but writing clean and efficient code is equally valuable. Good coding practices make themes easier to update, troubleshoot, and maintain.
Consider these best practices:
- Use meaningful variable names.
- Create reusable snippets instead of duplicating code.
- Keep Liquid logic organized and readable.
- Avoid unnecessary nested loops.
- Move repeated calculations and filtering operations outside loops when possible.
- Use conditional statements only when needed.
- Check for empty or unavailable values before displaying content.
- Keep HTML, CSS, JavaScript, and Liquid organized.
- Test your changes on different devices and screen sizes.
- Follow Shopify’s current theme development documentation.
Performance is also important. Unnecessary calculations and complex nested loops can increase Liquid rendering time. Optimizing how you process collections and product data can help improve theme performance.
Common Shopify Liquid Mistakes Beginners Should Avoid
When learning Liquid, beginners often encounter similar mistakes. Understanding these issues early can make the learning process much easier.
1. Confusing Objects and Tags
Objects use double curly braces, while tags use curly braces with percentage signs. Using the wrong syntax can prevent the expected output or logic from working.
2. Forgetting Closing Tags
Tags such as if, for, and capture require their corresponding closing tags. Missing them can cause Liquid errors.
3. Using Incorrect Object Properties
Not every Shopify object has the same properties. Always check the official Liquid reference before using unfamiliar objects or properties.
4. Creating Unnecessary Loops
Repeated or deeply nested loops can make your code harder to maintain and negatively affect performance.
5. Making Changes Directly to a Live Theme
Always duplicate your theme before making significant code changes. Preview and test your updates before publishing them.
6. Ignoring Theme Architecture
Modern Shopify themes use layouts, templates, sections, blocks, and snippets. Understanding how these files work together will help you avoid unnecessary code duplication and structural problems.
Useful Resources for Learning Shopify Liquid
If you want to improve your Liquid development skills, regularly practice with real Shopify theme files and explore the official documentation.
Some useful learning resources include:
- Shopify Liquid Documentation – Learn the fundamentals of Liquid objects, tags, and filters.
- Shopify Liquid Reference – Explore available Liquid objects, properties, tags, and filters.
- Shopify Theme Development Documentation – Understand theme architecture, sections, blocks, and templates.
- Shopify Cheat Sheet – Quickly find common Liquid syntax and examples.
- Shopify Theme Development Tutorials – Practice building real theme components.
These resources can help you move from basic Liquid concepts to more advanced Shopify theme development.
Learning Shopify Liquid is an important step toward becoming a skilled Shopify theme developer. It gives you the ability to work with dynamic store data, customize existing themes, create reusable components, and build more flexible eCommerce experiences.
Start by understanding objects, tags, and filters. Then practice creating variables, conditional statements, and loops. Once you are comfortable with the fundamentals, move on to building custom sections, snippets, product templates, and metafield-based features.
You don’t need to learn everything at once. Start with small projects, experiment with different Liquid features, and gradually work toward more advanced theme customization.
At Themetidy, we share practical Shopify development tutorials, theme customization tips, and eCommerce insights to help developers and store owners improve their online businesses. Explore more of our Shopify guides to strengthen your development skills and discover new ways to build better Shopify storefronts.
Founder & Shopify Expert
15+ Years of Experience
Ready to Build Your High-Converting Shopify Store?
Get a free store review and custom growth plan from a 15+ year Shopify expert.
Free Store Audit
Detailed analysis of your store performance
Actionable Plan
Step-by-step plan to increase sales & conversions
Expert Support
15+ years of Shopify experience by your side
15+
Years of Experience (Since 2010)
500+
Stores Built Worldwide
$100M+
Revenue Generated for Our Clients*
30+
Countries We Serve