-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Twitter og:description
doubly escaped by Hugo 0.125.x
#12418
Comments
I'll look at this again. Here's the challenge in the embedded opengraph template:
The input can be plain text, markdown, rendered markdown, HTML, or anything else. If rendered markdown, it might be wrapped in a |
Going back through issues, PRs, and forum topics, the best that I have come up with for consistent rendering regardless of how the summary is defined (front matter, with summary divider, without summary divider) is:
This handles the following cases the same way:
All three produce: <meta property="og:description" content="Test line with a single quote: can’t."> If this is acceptable:
|
Sounds good, thanks @jmooring. The OTel website has descriptions like the following (which I'm hoping to curate at some point to remove the images, but this is what we have now): description: >-
<img width="35" class="img-initial" src="/img/logos/32x32/Golang_SDK.svg"
alt="Go"> A language-specific implementation of OpenTelemetry in Go. And this (markdown): description: >-
_OTel in Practice_ is a _series_ of talks initiated by some members of the End
User SIG. Will the solution you propose handle such descriptions as before (or better :)? /cc @svrnm @theletterf |
With the proposed changes, the first is rendered to: <meta property="og:description" content=" A language-specific implementation of OpenTelemetry in Go."> The second is rendered to: <meta property="og:description" content="OTel in Practice is a series of talks initiated by some members of the End User SIG."> |
- Do not escape HTML entities - Use consistent formatting for title and description with opengraph, schema, and twitter_cards - Improve readability of twitter_cards Closes gohugoio#12418
Thanks @jmooring, that LGTM. |
In its current implementation, PR #12425 does this:
<meta property="og:description" content=" A language-specific implementation of OpenTelemetry in Go.">
<meta property="og:description" content="_OTel in Practice_ is a _series_ of talks initiated by some members of the End User SIG."> In your second example, note that the markdown is not rendered to HTML due to performance concerns related to using .RenderString on every og:description on every page. If you want to render the markdown and don't care about a performance hit, use this in the override template...
I have no idea how much this would affect a 10,000 page site. |
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. |
If you build this small repro (test-site-2024-04-23.zip) using Hugo 0.124.1 and 0.125.2, you'll see the following difference in the
content
of<meta property="og:description">
for http://localhost:1313/docs/page:Notice that 0.125.2 doubly escapes the
content
, so that:can’t
becomescan&rsquo;t
This seems wrong to me. WDYT?
Below I include a bit more header context.
Hugo 0.124.1:
Hugo 0.125.2:
The text was updated successfully, but these errors were encountered: