Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Frontmatter metadata get wrongly escaped quotes when rendered

Solved by pamtbaau View solution

Started by John 3 years ago · 2 replies · 451 views
3 years ago

Hi everyone,

I find myself with the following problem and I would like to know if this rings a bell to anyone:

The metadata values I set in the frontmatter of any page ends up with wrongly escaped quotes when the page is rendered.

Here is a sample of the metadata section from my page's frontmatter:

TXT
metadata:
  'og:title': Page's Title with quote
  'og:site_name': Site's name with quote

And here is what I get in the rendered page:

HTML
<meta property="og:title" content="Page&amp;apos;s Title with quote" />
<meta property="og:site_name" content="Site&amp;apos;s name with quote" />

It looks like the quote is transformed as "'" and then the "&" is escaped as "&".

I never had any issue with rendering quotes from other frontmatter values until now.
I'm pretty sure I am missing something obvious. :)

I'm running Grav v1.7.41.1 and here is my list of activated plugins (all up to date):

  • Breadcrumbs
  • Error
  • Flex Objects
  • Pagination
  • Problems
  • Shortcode Core
  • Simplesearch
  • Taxonomy List

Did anyone already encounter this kind of issue?

Any pointer to debug this would be much appreciated 🙂

3 years ago Solution

@rabooman, Using latest Grav 1.7.41.1 and theme Quark, I cannot reproduce your issue.

Template /system/templates/partials/metadata.html.twig used by Quark will generate the following output using your snippet:

HTML
<meta property="og:title" content="Page&apos;s Title with quote" />
<meta property="og:site_name" content="Site&apos;s name with quote" />
👍 1
3 years ago

Thanks a lot for your quick answer, you solved my problem!

The theme I'm using, which is based on Quark, modified the metadata.html.twig and modified the escape filters (I don't know why).
I had too quick of a look on the file the first time and missed this, and your comment made me look at it again.

So, thanks! 🙂

Suggested topics

Topic Participants Replies Views Activity
Support · by webmasterodp, 1 week ago
4 163 1 week ago
Support · by nwhitfield, 1 week ago
2 142 1 week ago
Support · by stell, 3 weeks ago
5 374 2 weeks ago
Support · by gravinator, 1 month ago
5 567 2 weeks ago
Support · by Gravver, 3 weeks ago
6 354 3 weeks ago