如何去除 Jekyll 中的白色 space?

How to remove the white space in Jekyll?

在 Jekyll 模板中,使用的 Liquid 标签会产生大量空白。从 Liquid 的文档中,使用 {{- -}}{{% %}} 可以去掉这些空格。

但我在构建 Jekyll 时得到了 Liquid syntax error

如何解决这个问题或者你有任何其他方法来删除空格?

有多个 Gem 会移除白色 space post build.

https://github.com/itafroma/jekyll-newline_collapse

https://github.com/stereobooster/html_press

{{-{%- 标签存在于最新的 Liquid 测试版中,但 Jekyll 使用最新的稳定版本,其中不包含这些标签。

当 Liquid 4.0 稳定发布时,Jekyll 的下一个版本应该包含该更新,因此这些标签将可用于 Jekyll 站点。

我已成功使用删除方法并指定空白 space:

Input
{{ "Multiple words here" | remove: " " }}

Output
Multiplewordshere

不确定这是否特定于 Shopify,但您可以尝试使用 strip filter

输入{{ " So much room for activities! " | strip }}

输出So much room for activities!

Jekyll v4 支持使用 {{%- test_function -%}}{{- variable -}} (details)。

否则可以使用the compression分机。