Hello guys, I’m trying to add some ads to Ghost, I still have to learn a little how the whole platform works but I have an idea so far.
I looked here but didn’t help
I’m trying to add google Adsense, I tried inserting the whole code in posts.hbs under <section class="post-full-content"> but that didn’t work. I also tried inserting the main script
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
to the default.hbs header, then:
That happens if the site is in production mode. From the docs:
In production mode, the template files are loaded and cached by the server ready to send to the browser. This means that if you make changes to a *.hbs file, you won’t see those changes reflected unless you restart Ghost. This doesn’t happen in development mode, and so pages will take a little longer to get generated, but it makes creating your theme much easier.
(Theme development guide)
Production mode is designed to be efficient (i.e. production ready), so there are things like aggressive caching.
Development mode is designed to let you have a ghost installation similar to a playground, so it’s less efficient to promote comfort - i.e. less caching -> changes you make show up almost instantly
Because of the way ghost runs, you generally shouldn’t switch an instance between development and production mode, especially since installing a local version is usually painless, but you’re more than welcome to. You just need to tell ghost to use the development config - ghost start -D will run ghost in development mode
If you don’t want to restart ghost every time you make changes, you can upload a zip of your theme in the settings/design panel and ghost will internally reload the components that need to be refreshed
And another quick workaround if in production mode, from Settings > Design > Themes, would be to just activate any other theme for a moment (e.g. the default Casper or another one), and then back to the theme we are using. Theme modifications are effective after this as well.
For me it worked perfectly fine. I just pasted the google ad code in the code injection page and google ad started showing on my post page. After adding the google code however, I didn’t see the ads directly because of ad blocker, then I whitelisted my domain to allow ads. You can check my blog at https://iamninad.com
That’s OK for a moment to verify the ads are working. After that, it’s advisable to block them again on our browser (or in our etc/hosts file), to prevent accidentally clicking on our own ads. As it’s well-know, many publishers have lost their AdSense account that way.
The problem is that I wasn’t approved by adsense. This is the first time I play with ads and google gives you the code, but doesn’t tell you have to be approved somewhere else.