Liquid syntax error: 'if' tag was never closed

Knowledge Drop

Last tested: Nov 30, 2020
 

Liquid tags can't have spaces between { and % or % and } .

For example, if we have:

{% if view_name.field_name._in_query %}

something to insert if true

{% else %}

something to insert if false

{ % endif % }

...we will see this error because the last line { % endif % } has these extra spaces. Removing any extra spaces (i.e., using {% endif %}) will resolve the error.

Other possible syntax issues (https://talk.jekyllrb.com/t/liquid-if-statement-error/2953):

  • We're missing a % somewhere.
  • We're missing a closing statement in our conditional logic.

This content is subject to limited support.                

Version history
Last update:
‎06-14-2021 06:17 PM
Updated by: