Close Menu
Global News HQ
    What's Hot

    City shrugs off concerns about 14 Wall Street lease 

    June 30, 2025

    The One Item You Should Never Put in a TSA Bin—and What to Do Instead

    June 30, 2025

    CGDV Is a Popular Dividend ETF for Passive Income. But Is It the Best? | The Motley Fool

    June 30, 2025
    Recent Posts
    • City shrugs off concerns about 14 Wall Street lease 
    • The One Item You Should Never Put in a TSA Bin—and What to Do Instead
    • CGDV Is a Popular Dividend ETF for Passive Income. But Is It the Best? | The Motley Fool
    • AT&T Will Pay $177M to Settle 2 Massive Data Breaches. Here's Who Can File a Claim
    • Tokenized stock trading live on Kraken, Bybit and Solana’s DeFi ecosystem
    Facebook X (Twitter) Instagram YouTube TikTok
    Trending
    • City shrugs off concerns about 14 Wall Street lease 
    • The One Item You Should Never Put in a TSA Bin—and What to Do Instead
    • CGDV Is a Popular Dividend ETF for Passive Income. But Is It the Best? | The Motley Fool
    • AT&T Will Pay $177M to Settle 2 Massive Data Breaches. Here's Who Can File a Claim
    • Tokenized stock trading live on Kraken, Bybit and Solana’s DeFi ecosystem
    • How Co-Citations Drive AI SEO
    • Why So Many Beauty Founders Are Morphing Into Gurus
    • How to Navigate JFK When It’s Under Construction
    Global News HQ
    • Technology & Gadgets
    • Travel & Tourism (Luxury)
    • Health & Wellness (Specialized)
    • Home Improvement & Remodeling
    • Luxury Goods & Services
    • Home
    • Finance & Investment
    • Insurance
    • Legal
    • Real Estate
    • More
      • Cryptocurrency & Blockchain
      • E-commerce & Retail
      • Business & Entrepreneurship
      • Automotive (Car Deals & Maintenance)
    Global News HQ
    Home - E-commerce & Retail - Plain-English Guide to Shopify Liquid
    E-commerce & Retail

    Plain-English Guide to Shopify Liquid

    Facebook Twitter Pinterest LinkedIn Tumblr WhatsApp VKontakte Email
    Plain-English Guide to Shopify Liquid
    Share
    Facebook Twitter LinkedIn Pinterest Email


    Liquid is Shopify’s template engine that brings backend store data to the public-facing front-end. Merchants who understand Liquid can unlock new store customizations without needing a developer.

    In this article, I will explain the basics.

    Liquid is a bridge between a store’s content and how it’s displayed. The template resides in a file with the .liquid suffix for every page or section. Hence main-product.liquid contains the product template.

    The product template resides in main-product.liquid. Click image to enlarge.

    Shopify organizes files based on what they do. For example, the “sections” folder contains files defining entire parts of a site, such as headers or a product gallery. The “snippets” folder applies to smaller components, such as buttons or a specific design element.

    Snippets can reside in section folders. A merchant could create a custom button in a snippet file and include it in the section folder, for example. To place “snippet_name.liquid” inside “main-product.liquid,” I would position my cursor at the right point in the product file and add {% render ‘snippet_name’ %}.

    Syntax

    Liquid functions with defined terms and phrases — a syntax.

    Variables

    Variables are the representation of dynamic information. For example, {{ product.title }} dynamically displays the title of the product. Note how Liquid uses double curly braces ( {{ }} ) to pull the variable information.

    Objects

    Objects are collections of data. Examples include product, collection, and customer.

    • product holds all the information about a specific product, such as title, ID, description, and price. To display a product’s price, create a variable {{ product.price }} where product is the object and price is the property. Shopify publishes a list of all product object properties.
    • collection represents a group of products, such as a category. Pull information from the collection object for every product assigned to it or for assigned information such as title, description, and product count. Here’s Shopify’s list of collection properties.
    • customer contains info about the logged-in user, such as name, email address, physical address, marketing consent, and order preferences. Here are all customer properties.

    Tags

    Tags add logic to Liquid code via two main types, “control flow” and “iteration.”

    Control-flow tags drive logic, such as if/else statements.

    {% if product.available %}
    This product is in stock!
    {% else %}
    Sorry, this product is out of stock.
    {% endif %}

    Iteration tags repeat actions, such as looping through products in a collection.

    {% for product in collection.products %}
    {{ product.title }}
    {% endfor %}

    Filters

    Filters transform the data Liquid retrieves. For example:

    • {{ product.title | upcase }} displays the product title in uppercase letters.
    • {{ product.price | times: 1.2 }} increases the price by 20%.

    Custom Message Example

    Here’s a real-life example. Imagine you want to display a custom message on your product pages under the title when an item is in stock or out of stock.

    Here’s how to do it.

    1. In the Shopify admin, navigate to Online Store > Themes > Actions (left button with dots …) > Edit Code.
    2. Find and open the main-product.liquid file from the sections folder.
    3. Search {%- when ‘title’ -%} using (Ctrl + F) to locate the title.

    Position the cursor under the closing /div and add:

    {% if product.available %}
    

    This product is available! Get it while stocks last!

    {% else %}

    Sorry, this product is currently out of stock.

    {% endif %}
    Screenshot of code for adding the custom message.

    Add a custom message when an item is in stock or out of stock. Click image to enlarge.

    Save and preview. Save your changes and preview the store. In this example, shoppers will see a green message when an item is in stock and a red message when out of stock.

    Screenshot of "Super Skinny Jean" product page with the red "out of stock" message

    The message “Sorry, the product is currently out of stock” appears in red. Click image to enlarge.

    Getting Started

    Experimenting and testing is the best way to learn.

    • Back up your theme. Always duplicate your theme before changing it. Click Actions > Duplicate in the Themes section of the admin.
    • Use Preview mode. Shopify allows previews of changes before taking them live.
    • Start small. Begin with minor changes.

    For more on Liquid, see:



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr WhatsApp Email
    Previous ArticleI'm An Optometrist & Here's Why You Need To Stop Rubbing Your Eyes
    Next Article Congressman introduces bill to abolish Federal Insurance Office

    Related Posts

    How Co-Citations Drive AI SEO

    June 30, 2025

    The shift in eCommerce: How sellers are finding growth beyond legacy marketplaces

    June 30, 2025

    What’s Worse than Lost FBA Inventory? When Amazon Finds It

    June 30, 2025

    7 Ways to Prep for Holiday Selling

    June 29, 2025
    Leave A Reply Cancel Reply

    ads
    Don't Miss
    Real Estate
    3 Mins Read

    City shrugs off concerns about 14 Wall Street lease 

    The Department for the Aging is moving ahead with an office lease that hit a…

    The One Item You Should Never Put in a TSA Bin—and What to Do Instead

    June 30, 2025

    CGDV Is a Popular Dividend ETF for Passive Income. But Is It the Best? | The Motley Fool

    June 30, 2025

    AT&T Will Pay $177M to Settle 2 Massive Data Breaches. Here's Who Can File a Claim

    June 30, 2025
    Top
    Real Estate
    3 Mins Read

    City shrugs off concerns about 14 Wall Street lease 

    The Department for the Aging is moving ahead with an office lease that hit a…

    The One Item You Should Never Put in a TSA Bin—and What to Do Instead

    June 30, 2025

    CGDV Is a Popular Dividend ETF for Passive Income. But Is It the Best? | The Motley Fool

    June 30, 2025
    Our Picks
    Real Estate
    3 Mins Read

    City shrugs off concerns about 14 Wall Street lease 

    The Department for the Aging is moving ahead with an office lease that hit a…

    Travel & Tourism (Luxury)
    3 Mins Read

    The One Item You Should Never Put in a TSA Bin—and What to Do Instead

    A travel expert is warning airline passengers against a common mistake at security.The expert says…

    Pages
    • About Us
    • Contact Us
    • Disclaimer
    • Homepage
    • Privacy Policy
    Facebook X (Twitter) Instagram YouTube TikTok
    • Home
    © 2025 Global News HQ .

    Type above and press Enter to search. Press Esc to cancel.

    Go to mobile version