Skip to content

else

An else can only exists within a condition statement, and is triggered when your preceding condition(s) where not met and you wish to default to something.

INFO

else can only be used with the following tags: if, case and unless.

liquid
{% else %}
  block_to_output
  • block_to_output: Rendered expression where no previous conditions were met.

Example

Data
json
{
  "product": {
    "track_inventory": true
  }
}

Note: Data is only refereed as a reference for this example and is in no means reflecting real world data.

liquid
{% if product.track_inventory == true %}
  <span>There only 15 items left. Hurry up!</span>
{% else %}
  <span>Supply is limited. Hurry up!</span>
{% endif %}

Output

There only 15 items left. Hurry up!