Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

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

Started by Muut Archive 10 years ago · 1 replies · 1279 views
10 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

10 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 Muut Archive, 10 years ago
1 673 1 week ago
Archive · by Deleted User, 9 years ago
0 3043 9 years ago
Archive · by Muut Archive, 9 years ago
2 1983 9 years ago
Archive · by Muut Archive, 9 years ago
2 5336 9 years ago
Archive · by Muut Archive, 9 years ago
1 4134 9 years ago