What's the deal with "Found a Liquid block containing the excerpt separator "\n\n"."

I am using jekyll to create my github site. I have this code:

---
layout: articles_home
title:  "Articles"
date:   2020-11-04 10:22:58 +0530
categories: souravgoswami blogs articles
description: "Sourav Goswami | Articles"
permalink: "articles"
active: "articles"
stylesheet: "/assets/css/articles"
---
<div class="row">
	{% for i in site.articles %}
			<div class="col-md-4">
				<div class="card shadowed rounded">
					<a href="{{ i.url }}">
						<div class="content-image" data-content="Read">
							<img class="card-img-top" src="{{ i.ogimage }}">
						</div>
					</a>
					<div class="card-body">
						<a href="{{ i.url }}">
							<h5>

								{{ i.title }}
							</h5>
						</a>
						<date>{{ i.date | date: "%d %B, %Y" }}</date>
						<a href="{{ i.url }}">Read article</a>
					</div>
				</div>
			</div>
	{% endfor %}
</div>

And every time I save a file, I get ]

           Warning: Excerpt modified in _posts/2020-11-19-articles.html!
                    Found a Liquid block containing the excerpt separator "\n\n". 
                    The block has been modified with the appropriate closing tag.
                    Feel free to define a custom excerpt or excerpt_separator in the
                    document's Front Matter if the generated excerpt is unsatisfactory.

Note the lines:

<h5>

    {{ i.title }}
</h5>

Every time I introduce a new line anywhere, the warning is printed. But If I have a continuous code without line breaks in the for loop, nothing is shown.

If I copy the same code to the layout, I get no warnings like that as well. The warning is only raised in a theme.

SO what’s wrong having one line break in the file?

An except is the first paragraph of a post. It could be an image or anything. It is the first thing that appears which is followed by two line breaks. That is the default separator at least

I am going to show \n here literally for demonstration

i.e.

My first paragraph.\n
\n
Next paragraph 

If the first text on your post starts with line breaks inside your html tag, that might be the cause of the warning.

Have a look at your posts page or home page - wherever the theme shows a list of posts as title and excerpt


Excepts aside, in markdown when you have one \n only will _not_render it.

ie

My first paragraph.
Next paragraph 

Will render as

<p>My first paragraph. Next paragraph</p>

And that I would guess is the reason for the warning

But two \n characters which means one empty line

My first paragraph.

Next paragraph 

Will translate as

<p>
My first paragraph.<br>
<br>
Next paragraph 
</p>

It might actually be two p tags but the point is that the empty line is rendered in HTML.

Try that out in your GitHub README.md to see what happens when you save markdown and view it

The reason for the warning is not because of Markdown, but because of the Liquid block tag.
When you have a Liquid block containing a blank line in the first paragraph, the default excerpt will not have valid Liquid construct because the closing tag of the block will not be included.

Consider the following example as a document’s content:

Lorem ipsum dolor
{% for foo in site.foobar %}

  {{ foo.title }}
{% endfor %}

The extracted unrendered excerpt object from the above doc, by default would just contain:

Lorem ipsum dolor
{% for foo in site.foobar %}

which is an invalid Liquid syntax and would abort the whole build when the excerpt is being rendered.
To overcome this, Jekyll inserts the closing tag to appease Liquid which makes the above unrendered excerpt content to be:

Lorem ipsum dolor
{% for foo in site.foobar %}
{% endfor %}

The build proceeds without any issue but the rendered excerpt won’t be as expected by the author.
Hence Jekyll issues a warning that it has interfered on the author’s behalf but cannot guarantee a satisfactory output and to do the needful by opting for a different excerpt-separator or changing the placement of the blank line.

1 Like

This is resolved if you start using the concept of layouts. A layout has no excerpt. Your content/markdown file then no longer use Liquid. All Liquid will move to your layout. Does that make sense?