How to add Ad's after each Divider? {{Content}}

Hi Folks, Developers,

Happy New year, I hope this year is glorious to you all.

I was wondering if anyone has implemented a way to add ‘Google Ads’ to the Middle Content of Articles?

Specifically, I want to have ads on top of each Divider in my Articles. (as these are the end of my Sections/Chapters) (without having to code inject them into every article)

Is there a way to manipulate {{Content}} in post.hbs to do this?

Any help is appreciated.

You can add an ad block with an HTML snippet - put the code provided into an HTML card, and save it as a snippet to make it easy to use.

Alternatively, you could write some javascript that inserts the ad blocks for you on the fly, since dividers mark where you want them anyway. You’d have to get the timing sorted out - you’d need to modify the html with the javascript before the google ad code runs to insert the ads.

Hi Cathy,

Thanks for the response, I like the idea of using the Snippet, however we have over 600 articles, with articles ranging from a few 300 words all the way up-to 3,000 words, and I am just trying to justify how ‘long’ this would take.

The second option sounds like something I am looking for, but again, if there was a way to manipulate the {{content}} helper without having to run a script this would be great. I only say, as running a script would cause increased load times, potentially affecting SEO.

I know that dividers are <‘hr’> in HTML, do you think there is any way of saying
"If {{Content}} contains <‘hr’> add {{<“ad-articles”}} before <‘hr’>

as an expression to use or if it’d even work?

Thank you

Handlebars as implemented by Ghost doesn’t do any logic like that.

Another option would be to retrieve posts from the API and rewrite to include the ad slots. Then you could use the snippet approach going forward, or trigger the rewrite with webhooks.

I want to do the same thing but I can’t and I don’t know why…

I have a ghost blog with automatic adsense. They are working but not between each paragraphs…