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

Insert <script type="application/ld+json"> to head from single page content

Started by Muut Archive 9 years ago · 1 replies · 1094 views
9 years ago

Hi Grav community,

I cannot find any solution for how to add <script type="application/ld+json">....</script> to head from page content. I'm try with TWIG assets.addInlineJs, but I get error 0 - Unexpected character "@", because of the JSON.

Thanks in advance.
Blaz

9 years ago

addInlineJs only accepts a javascript string, not a <script> tag containing it. You can add {{page.header.header_script}} to the theme's base.html.twig template, before the </head>, and add header_script: '<script type="application/ld+json">test</script>' into your page header.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1336 9 years ago
Archive · by Muut Archive, 9 years ago
2 926 9 years ago
Archive · by Muut Archive, 9 years ago
2 4056 9 years ago
Archive · by Muut Archive, 9 years ago
1 2941 9 years ago
Archive · by Muut Archive, 9 years ago
3 1112 9 years ago