Skip to content
Grav 2.0 is officially stable. Read the announcement →
Support

Meta tags rendering html codes

Started by Nicole Mitchell 9 years ago · 3 replies · 881 views
9 years ago

Hello!

I'm (very) new to Grav and I'm having some trouble with the meta tags. Tags with single quotes and ampersands are rendering the HTML code instead of the character I need (ex. How to Inspect a Car's Interior & Exterior). Can anyone point me in the right direction to fix this?

Thank you!

9 years ago

My title tag looks like this

<title>{% if page.metadata.title.content %}{{ page.metadata.title.content|e('html') }} | {% elseif header.title %}{{ header.title|e('html') }} | {% endif %}{{ site.title|e('html') }}</title>

I'm trying to add an {{% autoescape %} to the title tag, and it works in the header.title case, but not in the page.metadata.title.content case

9 years ago

I figured it out! If anyone is looking for the solution hopefully this can help them :)

TWIG
`{% if page.metadata.title.content %}{% autoescape false %}<title>{{  page.metadata.title.content|raw|replace({'&#039;' : '\'', '&amp;' : '&'}) }} | {{ site.title|e('html') }}</title>{%  endautoescape %}{% elseif header.title %}{% autoescape %}<title>{{ header.title|e('html') }} | {{ site.title|e('html') }}</title>{%  endautoescape %}{% endif %}`

Suggested topics

Topic Participants Replies Views Activity
Support · by Anna, 14 hours ago
1 43 7 hours ago
Support · by gtx, 1 week ago
4 227 1 day ago
Support · by Paul Hodges, 2 weeks ago
13 274 5 days ago
Support · by Anna, 3 weeks ago
9 333 1 week ago
Support · by TomW, 2 weeks ago
4 187 1 week ago