unless tag doesn't work as expected

unless tag doesn't work as expected

Shopify Partner
3 0 1


I have a question regarding the {%- unless -%} tag, as for me it doesn't work as expected.


If you follow shopify documentation about unless tag, it described like that.


Renders an expression unless a specific condition is true.

Here is my code for main-page.liquid section which is displayed via page.json template. I am using blank development theme with Shopify CLI. 

This code doesn't execute page.title and page.content, but executes assigned variable after else tag.

Why it is happening?

{%- assign message = "This page content is empty, please visit other page" -%}

{%- unless page.title and page.content != blank -%}
    {{ page.title }}
    {{ page.content }}
    {%- else -%}
     <p class="text-blue-600 text-5xl">{{- message -}}</p>
{%- endunless -%}

My page title and page content is filled up with information in Shopify backend. It isn't blank, as title and content contains some information - such as page title and some sentences in page content.

Can someone help me with this?


Replies 0 (0)