Insites Docs Developers liquid Liquid Whitespace Control

Liquid Whitespace Control

Last updated on June 18, 2024

In Liquid, you can include a hyphen in your tag syntax , , , and to strip whitespace (including line breaks) from the left and/or right side of a rendered tag.

Normally, even if it doesn’t output text, any line of Liquid in your template will still output a blank line in your rendered HTML:

Input

Notice the blank line before “tomato” in the rendered template:

Output

Trim whitespace before

Using a hyphen on opening tags ( and ) will trim white space from the content before the tag.

Input

Output

Trim whitespace after

Using a hyphen on closing tags ( and ) will trim white space from the content after the tag.

Input

Output

Trim whitespace before and after

Using hyphens on both opening and closing tags (, , , and ) will trim white space from both sides of the tag.

Input

Output

Note

This topic is a compilation of knowledge found at Shopify Themes, Liquid Documentation, Liquid Gem Documentation, and Liquid for Designers.

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.