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

Plainify summary text in internal meta templates #8562

Closed
shelbyspees opened this issue May 23, 2021 · 3 comments
Closed

Plainify summary text in internal meta templates #8562

shelbyspees opened this issue May 23, 2021 · 3 comments

Comments

@shelbyspees
Copy link

shelbyspees commented May 23, 2021

If not a bug, it's at least an interesting quirk. I recently started using semantic line breaks in all my markdown files, including my blog. I tend to use Hugo's <!--more--> feature to generate a post summary, and this summary gets used in a number internal templates for Schema.org, Twitter cards, and OpenGraph metadata. These internal templates are preserving the hard line breaks, which then show up in link previews in chat apps and on social media.

I'll use the example of a recent blog post I wrote (archived here). Here's that post's summary text with semantic line breaks:

Back in April I was lucky to get an early invite to
[Polywork](https://www.polywork.com/)
and I'm really liking the platform so far.
If you've ever wished you could point people to a single site that shows
all the cool stuff you've done and some more cool stuff you're working on,
Polywork is for you.

The post itself renders fine, but when I shared the post in Discord, the summary text had kept all the hard line breaks:

screenshot of blog unfurl in discord with seemingly random line breaks in the page summary

Definitely not what I was going for. I poked around in devtools on that page and noticed that <meta name="description" ...> behaves normally, but <meta name="twitter:description" ...> and <meta itemprop="description" ...> maintain the hard line breaks.

screenshot of blog post HTML in Chrome devtools showing one description that looks like normal text, and more descriptions with seemingly random line breaks

It turns out that in my site's theme, <meta name="description" ...> uses the plainify function on the summary:

<meta name="description" content="{{ if .IsHome }}{{ .Site.Params.homeSubtitle }}{{ else }}{{ .Summary | plainify }}{{ end }}" />

Hugo's internal templates for Schema.org, Twitter cards, and OpenGraph don't use plainify on summary text, and that seems to explain why they're all maintaining the hard line breaks, which then get grabbed by third parties and rendered in link previews.

Would it make sense to call plainify on the summary text in these internal templates? If so, I'd be willing to open a PR with the change.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@chalin
Copy link

chalin commented Jul 19, 2022

I think that this is still relevant because the issue hasn't been resolved, and hopefully will be addressed by #9856 or similar.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants