# How to add ads from google Adsense

**URL:** <https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057>\
**Category:** Developer help\
**Created:** [July 18, 2018, 3:47pm UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057 "2018-07-18T15:47:01Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![afern247](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/afern247/32/10894_2.png) [@afern247](https://forum.ghost.org/u/afern247)\
**Post date:** [July 18, 2018, 3:47pm UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057/1 "2018-07-18T15:47:02Z")

</div>

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](https://forum.ghost.org/t/facebook-ads-and-analytics/1138/3) 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:

`<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>`

this other on the bottom of the body and finally on the posts.hbs under `<section class="post-full-content">` I placed:

```
<ins class="adsbygoogle"
     style="display:block"
     data-ad-format="fluid"
     data-ad-layout-key="..."
     data-ad-client="..."
     data-ad-slot="..."></ins>

```

As you can probably tell it doesn’t work.

What would be the proper way to insert ads?

Thanks

---

<div class="post-metadata">

**Author:** ![Juan](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/juan/32/25_2.png) [@Juan](https://forum.ghost.org/u/Juan)\
**Post date:** [July 18, 2018, 5:35pm UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057/2 "2018-07-18T17:35:50Z")

</div>

> [@afern247](#):
>
> I’m trying to add google Adsense, I tried inserting the whole code in posts.hbs

It should work, unless you have an ad blocker enabled on your browser.

---

<div class="post-metadata">

**Author:** ![afern247](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/afern247/32/10894_2.png) [@afern247](https://forum.ghost.org/u/afern247)\
**Post date:** [July 18, 2018, 5:56pm UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057/3 "2018-07-18T17:56:21Z")

</div>

for some reason it’s not working, also I’m testing the theme with a very basic h1 and it’s not working. I’m writing it in post.hbs

```
<section class="post-full-content">
   <h1>Test</h1>
   {{content}}
</section>

```

And that doesn’t show up at all when I open a post… weird… very very weird… any thoughts?

**I’m posting the logs so if someone else has the same question the see what’s up** 😆

EDIT: I just removed {{content}} and it still shows up… could it be that I’m not editing the correct file? I mean there is only one…

EDIT2: I had to do:

`sudo systemctl reload nginx`  
and  
`ghost restart`

for the changes to take effect

---

<div class="post-metadata">

**Author:** ![Juan](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/juan/32/25_2.png) [@Juan](https://forum.ghost.org/u/Juan)\
**Post date:** [July 18, 2018, 6:17pm UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057/4 "2018-07-18T18:17:46Z")

</div>

> [@afern247](#):
>
> EDIT2: I had to do:
> 
> `sudo systemctl reload nginx`  
> and  
> `ghost restart`
> 
> for the changes to take effect

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](https://themes.ghost.org/docs))

---

<div class="post-metadata">

**Author:** ![afern247](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/afern247/32/10894_2.png) [@afern247](https://forum.ghost.org/u/afern247)\
**Post date:** [July 19, 2018, 12:32am UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057/5 "2018-07-19T00:32:41Z")

</div>

I’ll take a look into it. I pasted the ad code this morning and has not taken effect yet

The question is, how to switch between one and the other and what is the difference?

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [July 19, 2018, 4:38am UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057/6 "2018-07-19T04:38:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Juan](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/juan/32/25_2.png) [@Juan](https://forum.ghost.org/u/Juan)\
**Post date:** [July 19, 2018, 10:48am UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057/7 "2018-07-19T10:48:56Z")

</div>

> [@vikaspotluri123](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![Ninad\_Ingole](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ninad_ingole/32/1086_2.png) [@Ninad\_Ingole](https://forum.ghost.org/u/Ninad_Ingole)\
**Post date:** [July 29, 2018, 8:14am UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057/8 "2018-07-29T08:14:40Z")

</div>

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](https://iamninad.com)

---

<div class="post-metadata">

**Author:** ![Juan](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/juan/32/25_2.png) [@Juan](https://forum.ghost.org/u/Juan)\
**Post date:** [July 29, 2018, 10:13am UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057/9 "2018-07-29T10:13:35Z")

</div>

> [@Ninad\_Ingole](#):
>
> I didn’t see the ads directly because of ad blocker, then I whitelisted my domain to allow ads.

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.

---

<div class="post-metadata">

**Author:** ![afern247](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/afern247/32/10894_2.png) [@afern247](https://forum.ghost.org/u/afern247)\
**Post date:** [July 29, 2018, 8:56pm UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057/10 "2018-07-29T20:56:31Z")

</div>

Thanks for that info

---

<div class="post-metadata">

**Author:** ![afern247](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/afern247/32/10894_2.png) [@afern247](https://forum.ghost.org/u/afern247)\
**Post date:** [July 29, 2018, 8:57pm UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057/11 "2018-07-29T20:57:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/b/ba9ce5100b8bb264586f4f572545596b2ce3f081.png) [@system](https://forum.ghost.org/u/system)\
**Post date:** [August 12, 2018, 8:57pm UTC](https://forum.ghost.org/t/how-to-add-ads-from-google-adsense/2057/12 "2018-08-12T20:57:45Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
