jekyllliquidgithub-pagesliquid-layout

How to suppress blank line in Jekyll?


I use GitHub Pages for my blog, and am running into a problem with Jekyll. My post.html has a block like this:

{%    for testpost in site.posts   %}
{%           four                  %}
{%          lines of               %}
{%         processing              %}
{%         goes here               %}
{%    endfor                       %}

The part in the middle doesn't matter. The important part is the end of the line which is outside of the {% %} markup, and is therefore rendered into the html. Since this is in a loop, it's putting about 1000 blank lines into the middle of by HTML page. It doesn't affect the display, but it make a View/Source troublesome.

Any ideas on how to avoid those extra blank lines?


Solution

  • Since Liquid v4 (included in Jekyll from v3.5) there is a Whitespace control, which finally resolved case with blank line, white space, etc.

    Link to documentation: https://shopify.github.io/liquid/basics/whitespace/