How to add Google Adsense to Openshift Ghost Blog

Ghost is a simple opensource blogging platform that still under heavy development by their community. I use Openshift and Ghost Quickstart and updated to latest version. Still it already has many key features for blogger. But there is some lack of features such as, how can we monetize our blog? We have to modify or add a script ourself. This tutorial will guide you there.

First thing first, i assume you already have an adsense account, if not register it for free at Google Adsense site.

After you have an approved google adsense account, create an ad unit. There are several ad units to choose. I prefer create a responsive ad unit, and copy the ad code to be inserted to the script of our ghost site. We are not going to talk much about this ad unit size. This should be clear by the name of each ad unit size.
Create a responsive ad unit in google adsense dashboard In this tutorial, we will add adsense ad on top of each of our post. So we need to edit post.hbs. This file located at our theme folder that we choose. (I use default Casper Theme).

Using ssh, connect to your blog application and go to:
/pathofyourtheme/content/themes/casper/post.hbs In my case, i use openshift so i have to go to:
app-root/repo/content/themes/casper/post.hbs and edit that file using vim.

Google Adsense ad unit placed in post.hbs script of ghost blog theme Since we want to show the ads on top of each post, we insert google adsense ad unit below this line:
<h1 class="post-title">{{{title}}}</h1>

Save your changes and restart ghost blog application.

You can see the result on this page. Later on, depending on your needs and your theme, you can customize the ad placement where to show the ad. The principal how to add the code should the same. It only need a little understanding on html structure.

wahyu way

Tech savvy, mobile app consultant, hard worker, runner, traveller