In Jekyll templating, the Liquid tags used can generate a lot of white spaces. From Liquid's documents, use {{-
-}}
or {{%
%}}
can strip these white spaces.
But I got a Liquid syntax error
when Jekyll building.
How to fix this problem or do you have any other methods to remove the white spaces?
The {{-
and {%-
tags exist in the latest beta version of Liquid but Jekyll uses the latest stable version, which doesn't include those tags.
When there's a stable release of Liquid 4.0, the next release of Jekyll should include that update and thus those tags will be available to use on Jekyll sites.
Not sure if this is specific to Shopify, but you could try using the strip filter .
Input : {{ " So much room for activities! " | strip }}
{{ " So much room for activities! " | strip }}
Output : So much room for activities!
There is more than one Gem that will remove white space post build.
I have had success using the remove method and specifying a blank space:
Input
{{ "Multiple words here" | remove: " " }}
Output
Multiplewordshere
Jekyll v4 support using {{%- test_function -%}}
and {{- variable -}}
( details ).
Otherwise the compression extension can be used.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.