How to suppress blank line in Jekyll?

后端 未结 5 2009
梦谈多话
梦谈多话 2021-02-04 00:49

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   %}
{%                  


        
5条回答
  •  爱一瞬间的悲伤
    2021-02-04 01:20

    There's a nice workaround, that I found out in https://github.com/plusjade/jekyll-bootstrap/blob/master/_includes/JB/setup, and which is compatible with github pages.

    Just enclose your loop in a capture statement, and assign nil to the resulting var.

    {% capture cache %}
        {% for p in site.posts %}
           do stuff here
        {% endfor %}
    {% endcapture %}{% assign cache = nil %}
    

提交回复
热议问题