The Unless Tag
  • 04 Apr 2025
  • 1 minute read
  • Dark
    Light
  • PDF

The Unless Tag

  • Dark
    Light
  • PDF

Article summary

In Liquid markup, the unless tag is the functional inverse of the if tag: it displays content only if a specified condition evaluates as false.

Here’s a generic example of the unless tag in action:

{% unless export == condition %}
    Content to display if the value is found to be false
{% endunless %}

How the unless tag works

The unless tag checks the specified export against the condition.

  • If the condition is found to be false, the dynamic content inside the unless tag is executed

  • If the condition is instead found to be true, the dynamic content is ignored.

Examples

If the recipient’s sports interest level is Varsity, don’t show them anything; if their interest level is some other value, show them the content:

{% unless {{sport-interest-level}} == 'Varsity'%}
    We have plenty of Club and Intramural sports that you can get involved in! 
    Check them out here: {{sport-link}}
{% endunless %}

Unless an event’s location is Slate University, show the recipient the message “Your event is off-campus!”; otherwise, if the location is Slate University, don’t show them anything.

{% unless {{event-location}} == 'Slate University' %}
    Your event is off-campus!
{% endunless%}

These examples use ==, but other Liquid Markup operators can be used as well.

📖 Further reading: See the Shopify documentation on the unless tag


Was this article helpful?

What's Next