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

0.64.0 layouts/partials/post/excerpt.html displays images twice and in some cases too big #346

Closed
chrisrummel opened this issue Jan 15, 2022 · 12 comments

Comments

@chrisrummel
Copy link
Contributor

chrisrummel commented Jan 15, 2022

Describe the bug
The list view shows strange behaviour with the new layouts/partials/post/excerpt.html
Some preview images have the correct size, and while usually there should be only the posts text, the image is displayed a second time. With other posts the preview image is not small but huge, plus it gets displayed a second time.

Screenshots
(author removed screenshots)

expecteds behaviour
(author removed screenshots)

Hugo version:

hugo v0.92.0-B3549403+extended linux/amd64 BuildDate=2022-01-12T08:23:18Z VendorInfo=gohugoio
@razonyang
Copy link
Owner

@chrisrummel That is because v0.64.0 changed the summaries' selection order, see also #341 (comment) last point. But it isn't backward compatibility.

The issue is about the summary format, plain text or HTML. We can do this via summary parameter or manual splitting(<!--more-->), but it may be dull if there are a lot of posts. So I prefer defining a new parameter(TBD, may be post.plainifyExcerpt) that allow users to pick up the format.

@sagarbehere @chrisrummel What do you think?

@chrisrummel
Copy link
Contributor Author

@razonyang I see, the cause is a year old bug in hugo and there is nothing I could do against it besides copying excerpt.html from themes to local and modifying it to remove all HTML?

post.plainifyExcerpt sounds reasonable then, I guess.

@chrisrummel
Copy link
Contributor Author

chrisrummel commented Jan 16, 2022

I tested
{{- else -}}. {{- $readMore = false -}}. {{- $maxLength := default 320 $.Site.Params.post.excerptMaxLength -}}. {{- $content = .Content | plainify | truncate $maxLength $readMoreButton -}}
but that gives me unrendered htmlspecialchars.

@razonyang
Copy link
Owner

I tested {{- else -}}. {{- $readMore = false -}}. {{- $maxLength := default 320 $.Site.Params.post.excerptMaxLength -}}. {{- $content = .Content | plainify | truncate $maxLength $readMoreButton -}} but that gives me unrendered htmlspecialchars.

Use .Plain instead of .Content may works.

@chrisrummel
Copy link
Contributor Author

Use .Plain instead of .Content may works.

No, sadly it doesn't work.

@sagarbehere
Copy link
Contributor

@chrisrummel

  • Is this the issue you are getting when using plainify? If so, perhaps using htmlUnescape and safeHTML would help?
  • Another thing I can think of is just to use .Summary instead of .Content. That is how the HBS template originally did it. But this would mean that
    • You'll need to override the templates layout/partials/post/excerpt.html in your own site root dir
    • When this Hugo issue is fixed, this will stop working
  • Re: getting two images instead of one: Are you also using the images frontmatter variable? I was getting two images when I was using that variable AND the summary was not stripped of HTML

@razonyang I think post.plainifyExcerpt makes sense for those users who really do want to strip the HTML/Images/formatting from their summaries.

@razonyang
Copy link
Owner

razonyang commented Jan 17, 2022

@chrisrummel Could you please provide an example of content and expected screenshot for testing? Because you removed the screenshots, I can't test it by myself. You can also send it to me by e-mail.
I also remember that there is a table(not plain text) inside a summary shown in the screenshot you posted, but I'm not sure if that is expected.

@chrisrummel
Copy link
Contributor Author

@razonyang You can find a link to my site in the USERS.md and have a look at it.

@razonyang
Copy link
Owner

Closed by #351.

@sagarbehere FYI, the post.plainifyExcerpt was set as true by default, so that users won't be confused after upgrading the theme to v0.64.0 or above.

@chrisrummel
Copy link
Contributor Author

@razonyang The htmlUnescape seems to have an unwanted sideeffect - the printf "<p>%s</p>" paragraph-tags show in the excerpt.

@razonyang
Copy link
Owner

razonyang commented Jan 17, 2022

@chrisrummel It should be fixed by f429db8

@chrisrummel
Copy link
Contributor Author

@chrisrummel It should be fixed by f429db8

Indeed it is. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants