Developers · Liquid
Liquid Whitespace Control
Last updated 10 November 2026
In Liquid, you can include a hyphen in your tag syntax
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
{% assign my_variable = "tomato" %}
{{ my_variable }}Notice the blank line before “tomato” in the rendered template:
Output
tomatoTrim whitespace before
Using a hyphen on opening tags (
Input
Start
My paragraph
{{- "The end." }}Output
Start
My paragraphThe end.Trim whitespace after
Using a hyphen on closing tags (
Input
{{ "Start" -}}
My paragraph
The end.Output
StartMy paragraph
The end.Trim whitespace before and after
Using hyphens on both opening and closing tags (
Input
{{ "Start" -}}
My paragraph
{{- "The end." }}Output
StartMy paragraphThe end.Note
This topic is a compilation of knowledge found at Shopify Themes, Liquid Documentation, Liquid Gem Documentation, and Liquid for Designers.
Try it
Edit the input and press Run. The example runs on this site, read-only.