Liquid Cheat Sheet:
Here's a handy cheat sheet with bite-sized tutorials to help you master Liquid like a pro:
Variables
liquidCopy code {{ variable_name }}
Tutorial: Accessing Product Title
liquidCopy code
{{ product.title }}
Grab the title of your product and display it wherever you need.
Filters
liquidCopy code
{{ some_text | filter_name: parameter }}
Tutorial: Formatting Date
liquidCopy code
{{ order.created_at | date: "%B %d, %Y" }}
Turn a raw date into a human-readable format for order timestamps.
If Statements
liquidCopy code
{% if condition %}
Do something awesome!
{% endif %}
Tutorial: Showing Discount Banner
liquidCopy code
{% if cart.total_price > 100 %}
Hurry! You get a special discount on orders over $100!
{% endif %}
Display a discount banner for orders over a certain amount.
Loops
liquidCopy code
{% for item in collection %}
{{ item }}
{% endfor %}
Tutorial: Displaying Product Images
liquidCopy code
{% for image in product.images %}
<img src="{{ image.src }}" alt="{{ product.title }} Image">
{% endfor %}
Loop through product images and display them on your page.
Comments
liquidCopy code
{# This is a friendly comment! #}
Tutorial: Commenting for Clarity
liquidCopy code
{# Reminder: This section is for the product page layout #}
Leave notes to help yourself or your team understand specific sections.
Including Snippets
liquidCopy code
{% include 'snippet' %}
Tutorial: Including Related Products
liquidCopy code
{% include 'related-products' %}
Reuse a snippet to showcase related products across multiple pages.
Theme Settings
liquidCopy code
{{ settings.variable_name }}
Tutorial: Customizing Colors
liquidCopy code
{{ settings.primary_color }}
Use theme settings to easily customize primary colors throughout your site.
Reference this cheat sheet to learn more about Shopify Liquid!