Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page.excerpt behaviour changed between 4.0.1 and 4.1.0 #8216

Closed
seth-reeser opened this issue May 28, 2020 · 4 comments · Fixed by #8222
Closed

page.excerpt behaviour changed between 4.0.1 and 4.1.0 #8216

seth-reeser opened this issue May 28, 2020 · 4 comments · Fixed by #8222
Labels
frozen-due-to-age has-pull-request Somebody suggested a solution to fix this issue pinned

Comments

@seth-reeser
Copy link

seth-reeser commented May 28, 2020

Hello, version 4.1.0 introduced an unexpected change in behaviour for page.excerpt per pull request 7642.

I was using page.excerpt as a meta description entry:

<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">

In an example of an excerpt not being defined for a page, this would have evaluated to the site.description, but now I'm getting markup generated for me that breaks because of HTML being included.

I would recommend the new implementation approach things similarly by stripping html, stripping newlines, and even maybe truncating.

@ashmaroli
Copy link
Member

Is your site public @seth-reeser ? If yes, please provide us with a link to it.

@seth-reeser
Copy link
Author

seth-reeser commented May 28, 2020

@ashmaroli, unfortunately I cannot share the website publicly, but here's another example. The below snippet loops through each Jekyll page and generates a search.json file for consumption by a custom search mechanism:

Screen Shot 2020-05-28 at 2 44 41 PM

Given a page, in this example, a "Terms of Use" page that has no page.excerpt defined in it's markup; I would expect page.excerpt to be blank, but now it is not, nor a value that I want. I would expect this to be an issue for others as well.

Before (Jekyll 4.0.1):

Screen Shot 2020-05-28 at 2 48 27 PM

After (Jekyll 4.1.0):

Screen Shot 2020-05-28 at 2 47 11 PM

@ashmaroli
Copy link
Member

The reason I asked for a link to your website is so that I could see how exactly {{ page.excerpt | strip_html }} resulting in rendering HTML tags.
From your comments, I'm guessing that you do not have posts or collections in your site.

As a workaround to get to the old behavior, you can disable excerpts for all pages by setting front matter excerpt_separator: "". If you too many pages that you can't manually modify, you could use front-matter-defaults instead:

# _config.yml

defaults:
  - scope:
      path: ""
      type: pages
    values:
      excerpt_separator: ""

@seth-reeser
Copy link
Author

seth-reeser commented May 28, 2020

Here's before and after for the original meta description example. Keep in mind for this example, that there was no page.excerpt set for the page in question. So the fallback was site.description in this example:

<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">

Before (Jekyll 4.0.1) site.description fallback:

Screen Shot 2020-05-28 at 5 45 32 PM

After (Jekyll 4.1.0) new Jekyll logic now creates a page.excerpt from page content if not defined:

Screen Shot 2020-05-28 at 5 43 24 PM

Thank you for the excerpt_separator trick and agree that I can programmatically solve this issue - but I could foresee this be a breaking change for many others.

@ashmaroli ashmaroli pinned this issue May 29, 2020
@jekyllbot jekyllbot added the has-pull-request Somebody suggested a solution to fix this issue label Jun 1, 2020
@ashmaroli ashmaroli unpinned this issue Jul 5, 2020
@jekyll jekyll locked and limited conversation to collaborators Jun 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age has-pull-request Somebody suggested a solution to fix this issue pinned
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants