Prevent excerpts from being generated by default #2007

Closed
wants to merge 6 commits into from

4 participants

@ivantsepp

This is the continuation of #1869 and @troyswanson's work. I just adjusted it to the previous PR's comments, fix tests, and update documentation.


On a slightly related note, I tried to add the following test but was surprised to find it failing:

Scenario: An excerpt when the excerpt_separator is not present
  Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}"
  And I have a configuration file with "excerpt_separator" set to "<!-- excerpt_not_matching -->"
  And I have a _posts directory
  And I have a _layouts directory
  And I have a post layout that contains "{{ content }}"
  And I have the following posts:
    | title     | date       | layout  | content                                         |
    | entry1    | 2013-12-25 | post    | content for entry1. <!-- more --> more content. |
  When I run jekyll
  Then I should see nothing in "_site/index.html"

Looks like (on master) if I use an excerpt_separator that doesn't exist in the post, the entire post is used as the excerpt. Is this expected behavior?

@jekyllbot jekyllbot was assigned by parkr Feb 4, 2014
@troyswanson
Jekyll member

Whoa, I didn't even notice this. Thanks for picking up where my skills dropped off! 😉

@parkr
Jekyll member

Looks like (on master) if I use an excerpt_separator that doesn't exist in the post, the entire post is used as the excerpt. Is this expected behavior?

Definitely not what we intend, but if Post#generate_excerpt? returns true, the excerpt is created. This must be an artifact of String#partition, called in Excerpt#extract_excerpt.

@ivantsepp

Ah, that's why it's behaving like that. @parkr Should we change it so that extract_excerpt method will return an empty string if it didn't find the separator in the post content? I think that's better than returning the entire post.

@parkr
Jekyll member

change it so that extract_excerpt method will return an empty string if it didn't find the separator in the post content? I think that's better than returning the entire post.

make it so

@troyswanson
Jekyll member

😍 💖

@mattr- mattr- commented on the diff Feb 26, 2014
site/docs/posts.md
@@ -144,16 +144,15 @@ posts:
</ul>
{% endhighlight %}
-Because Jekyll grabs the first paragraph you will not need to wrap the excerpt in `p` tags,
-which is already done for you. These tags can be removed with the following if you'd prefer:
+You will not need to wrap the excerpt in `p` tags, which is already done for you.
@mattr-
Jekyll member
mattr- added a note Feb 26, 2014

Is this specific to the markdown renderer in use?

@parkr
Jekyll member
parkr added a note Feb 26, 2014

I think this happens for every Markdown renderer we currently support, e.g. #1162.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@parkr parkr closed this Mar 17, 2014
@parkr parkr reopened this Mar 17, 2014
@parkr parkr closed this Dec 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment