Documentation Index

Fetch the complete documentation index at: https://knowledge.technolutions.net/llms.txt

Use this file to discover all available pages before exploring further.

The Unless Tag

Prev Next

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

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 you can use other Liquid Markup comparison operators.

📖 See the Shopify documentation on the unless tag

Still looking for what you need?