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

Summary of posts are missing on index page with Hugo versions 0.134.0 and newer. #529

Open
McPringle opened this issue Dec 22, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@McPringle
Copy link

McPringle commented Dec 22, 2024

Describe the bug

In the past, the index page (home page) of my blog showed a post summary between the post title and the read more link. Since newer versions of Hugo (v0.134.0 and newer) the summary is not rendered any more on the home page. Please see the attached screenshots, where I rendered the same source with Hugo v0.133.1 and v0.134.0.

To Reproduce

Create a website which displays a summary of each post on the home page. Render the website using Hugo v0.133.1 and Hugo v0.134.0. Compare both websites.

Expected behavior
I expect the summary to be shown when rendering the same website using a newer Hugo version.

Screenshots
Rendering with Hugo v0.133.1:
image
Rendering with Hugo v0.134.0 and newer:
image

Desktop (please complete the following information):

  • OS: Linux
  • Browser: all
  • Version of the Theme: v1.16.0
  • Version of Hugo: v0.140.0 (tried v0.133.1 and v0.134.0, too)

Smartphone (please complete the following information):

I didn't tried it with a Smartphone.

Additional context

I did not overwrite, replace, or modify the theme files in any way.

In the release notes of Hugo v0.134.0 I found something about a (citation) slightly breaking change regarding the content summary handling.

@McPringle McPringle added the bug Something isn't working label Dec 22, 2024
@McPringle
Copy link
Author

McPringle commented Dec 22, 2024

Analyzing the HTML I found the following comment in the output files generated by Hugo v0.134.0+:

image

Using Hugo v0.133.1 and previous, that was the place where the summary was:

image

@McPringle
Copy link
Author

McPringle commented Dec 22, 2024

Hugo uses Goldmark to render Markdown to HTML. Goldmark marks HTML in Markdown files unsafe. Regarding the release notes of Hugo v0.134.0 the summary is now HTML, not markdown (if I understand it correctly). So Goldmark tries to render Markdown, which in reality is HTML, and replaces the HTML with the unsafe warning comment.

A quick and dirty workaround is to configure Goldmark using hugo.toml to allow unsafe HTML:

[markup.goldmark.renderer]
unsafe = true

This is a dirty hack because Goldmark should not be called with HTML code. I'm not familiar with Hugo template programming, but I think the pipe in the followin code is the problem:

image
https://github.com/lxndrblz/anatole/blob/master/layouts/index.html#L60C28-L60C39

Maybe the summary should be piped to safeHtml instead?

@lxndrblz
Copy link
Owner

@McPringle I'll have to look into this. Thanks for bringing this to my attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants