Close Menu
Global News HQ
    What's Hot

    Catching Falling Knives? Smart Strategies for Buying Stocks in a Downturn. | The Motley Fool

    June 9, 2025

    One of the World’s Greatest Wine Collectors Is Auctioning Off Prized Bottles

    June 9, 2025

    Gia Giudice Explains Why She’s Planning to Move Out of Her Family’s New Jersey Home: “It’s a Lot” | Bravo

    June 8, 2025
    Recent Posts
    • Catching Falling Knives? Smart Strategies for Buying Stocks in a Downturn. | The Motley Fool
    • One of the World’s Greatest Wine Collectors Is Auctioning Off Prized Bottles
    • Gia Giudice Explains Why She’s Planning to Move Out of Her Family’s New Jersey Home: “It’s a Lot” | Bravo
    • 9 Game-Changing Uses for Essential Oils to Freshen Up Your Cleaning Routine
    • I Struck Gold With This Viral Tiktok Video Where Travelers Reveal the Comfiest Walking Sandals—From $54
    Facebook X (Twitter) Instagram YouTube TikTok
    Trending
    • Catching Falling Knives? Smart Strategies for Buying Stocks in a Downturn. | The Motley Fool
    • One of the World’s Greatest Wine Collectors Is Auctioning Off Prized Bottles
    • Gia Giudice Explains Why She’s Planning to Move Out of Her Family’s New Jersey Home: “It’s a Lot” | Bravo
    • 9 Game-Changing Uses for Essential Oils to Freshen Up Your Cleaning Routine
    • I Struck Gold With This Viral Tiktok Video Where Travelers Reveal the Comfiest Walking Sandals—From $54
    • How to Advocate for Trans Rights in Your Community
    • Bigger than Coca-Cola? If Tether went public, it could reach a $515B valuation
    • Essential Backyard Pond Maintenance Tips for Every Season
    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

    Can One Person Run a Billion-Dollar Store?

    June 8, 2025

    eBay Changes ‘Budget Pacing’ for Priority Ad Campaigns

    June 7, 2025

    Signet Jewelers sales up 2% in Q1 earnings results

    June 7, 2025

    Dollar General raises sales outlook, plots next steps for ecommerce and retail media

    June 7, 2025
    Leave A Reply Cancel Reply

    ads
    Don't Miss
    Finance & Investment
    5 Mins Read

    Catching Falling Knives? Smart Strategies for Buying Stocks in a Downturn. | The Motley Fool

    As stock prices decline, you may feel as if you’re at the world’s biggest sale.…

    One of the World’s Greatest Wine Collectors Is Auctioning Off Prized Bottles

    June 9, 2025

    Gia Giudice Explains Why She’s Planning to Move Out of Her Family’s New Jersey Home: “It’s a Lot” | Bravo

    June 8, 2025

    9 Game-Changing Uses for Essential Oils to Freshen Up Your Cleaning Routine

    June 8, 2025
    Top
    Finance & Investment
    5 Mins Read

    Catching Falling Knives? Smart Strategies for Buying Stocks in a Downturn. | The Motley Fool

    As stock prices decline, you may feel as if you’re at the world’s biggest sale.…

    One of the World’s Greatest Wine Collectors Is Auctioning Off Prized Bottles

    June 9, 2025

    Gia Giudice Explains Why She’s Planning to Move Out of Her Family’s New Jersey Home: “It’s a Lot” | Bravo

    June 8, 2025
    Our Picks
    Finance & Investment
    5 Mins Read

    Catching Falling Knives? Smart Strategies for Buying Stocks in a Downturn. | The Motley Fool

    As stock prices decline, you may feel as if you’re at the world’s biggest sale.…

    Luxury Goods & Services
    8 Mins Read

    One of the World’s Greatest Wine Collectors Is Auctioning Off Prized Bottles

    This story is from an installment of The Oeno Files, our weekly insider newsletter to…

    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