How to use liquid unless loops in Shopify

Updated: July 07, 2021


Drive 20-40% of your revenue with AVADA
avada email marketing

Since 2006, Liquid has been used in Shopify as a language template. In Liquid, you use tags consisting of comment, control flow, iteration, raw, and variable to show complex content. In this tutorial, we will introduce you about unless statement so that you are able to display special code.

Table of content

A brief introduction to Liquid and tag types

There are three types in Liquid codes including objects, tags, and filters. Liquid use objects to show the location of the content on a page. Double curly braces denote objects and variable names. Filters change a Liquid object’s output. Tags create logic and control flow for a template. Tags begin with two curly braces and percent signs. Tags can be divided into three types: control flow, iteration, and variable assignment.

In control flow, there are five tags that you are able to use to upload dynamic content: if, unless, else, case/when. Today, tutorial guides you to use unless tag.

Let’s move to the next part to see how to display unless tags.

How to show unless tags

unless tags have opposite function with if tags. If tags execute a block of codes in case a certain condition is true while unless tags execute a block of code only if a certain condition is not met.

Look at the example below. In case you want to post a negative sentence which is these shoes are not awesome. In the input code, unless is put between two percent signs and besides product.title. Then you will see the result.


{% unless product.title == 'Awesome Shoes' %}
  These shoes are not awesome.
{% endunless %}


These shoes are not awesome.

The sample code is equivalent to if and endif code. You can write input code in this way without changing the output.

{% if product.title != 'Awesome Shoes' %}
  These shoes are not awesome.
{% endif %}


In conclusion, the tutorial aims to instruct you to use unless tags in Liquid. Unless tags help to respond to a block of code in case a certain condition is not met. You can use this type of tag to change from an affirmation sentence to a negative sentence. We hope that you will address your problems thanks to our blogs.

Recommend for you
Image Description
SMS, Email Marketing Automation

Top rated Marketing automation for Shopify stores

Learn more
Image Description
SEO Suite

Auto-optimize website elements and structure in one-click.

Learn more
Boost Sales [Free]

Boost sales: Sales Pop, Trust badges, Countdown timer, more

Learn more
Image Description
Photo Reviews [Free]

Use photo reviews to boost sales

Learn more


Stay in the know

Get special offers on the latest news from AVADA.

40k subscribers has been joined!

Earn $10 in reward now!

go up