Adsense-Script in GRAV-Content


I do my first steps with the GRAV-CMS and I like it :slight_smile:

But what I can not do is to add a google-ansense script direct into the content.

Google-Search with markdown and script was not successful.

Is there any markdown “command” for a script as below?

Thanks for help and best regards

You should rather add this directly in your template in user/theme/yourtheme/templates/

There is also a plugin just for this:


In the template doesn’t work, because the script has to be in the middle of the content.
And an editor without script knowlege should be able to change the script in the content.

Any other ideas?

I think you could still add the script on your template, and then add a inside markdown and then use jquery to append the ins tag inside the span.

oh, another idea:

  • script tags goes in template
  • create a twig file in partials/adsense.html.twig
  • include it in your markdown where you want with {% include 'partials/adsense.html.twig %}
  • check Process Twig: true in frontmatter

It should work!

Thanks for the answer.
Sounds very complicated… because I am not the real coding specialist.
Maybe I try it first with a iframe.
Iframe works in Markdown.

Goodle doen’t like adsense in iframe :frowning:

Any other “simple” ideas?

Thanks and best regards

Really, that is not hard, give it a try.
Create the file adsense.html.twig inside user/theme/yourtheme/templates/partials
This file should contain

<ins class=“adsbygoogle”

Then, in the editor, you can keep inserting your script here at first (even if it’s not really recommended), so it should look like this:

<script async src=“//”></script>
## this is some content

this is some paragraph with the adsense below
{% include 'partials/adsense.html.twig %}
the paragraph continue here
(adsbygoogle = window.adsbygoogle || []).push({});

it should work!