Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the white space in Jekyll?

Tags:

jekyll

liquid

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?

like image 370
Frank Lin Avatar asked Nov 27 '16 15:11

Frank Lin


People also ask

How do I get rid of whitespace?

Use the String. replace() method to remove all whitespace from a string, e.g. str. replace(/\s/g, '') . The replace() method will remove all whitespace characters by replacing them with an empty string.

How do I get rid of the white space at the end of a string?

To remove whitespace characters from the beginning or from the end of a string only, you use the trimStart() or trimEnd() method.

How do you remove the white space at the beginning of a string?

String result = str. trim(); The trim() method will remove both leading and trailing whitespace from a string and return the result.

What is liquid Jekyll?

Liquid is a templating language used in Jekyll to process your site's pages. In other words, it helps you make your HTML pages a bit more dynamic, for example adding logic or using content from elsewhere. This doesn't require any setup - we can just start using it.


2 Answers

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.

like image 150
Adam Hollett Avatar answered Sep 23 '22 21:09

Adam Hollett


Not sure if this is specific to Shopify, but you could try using the strip filter.

Input: {{ " So much room for activities! " | strip }}

Output: So much room for activities!

like image 22
Ty M Avatar answered Sep 23 '22 21:09

Ty M