You've successfully subscribed to Primates
Great! Next, complete checkout for full access to Primates
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

How to add ads.txt to your Ghost blog ?

Add the ads.txt file on your Ghost blog in less than 5 minutes. An easy method that will greatly increase your revenue

Stanislas Girard
Stanislas Girard

You have set up an AdSense or another ads provider on your website. You are serving ads, but your provider tells you to add an ads.txt. I'll shortly explain to you how to add the ads.txt easily and why you need it.

What is ads.txt?

The ads.txt – Authorized digital sellers -  specifies a mechanism for publishers to list their authorized digital sellers to fight against fraud and misrepresented domains.

Adding an ads.txt file to your website will provide an increased guarantee for the digital sellers and significantly increase your revenue.

I'll show you in less than 5 minutes how to add it to your website.

Adding the ads.txt

To add the ads.txt file to your Ghost blog, you'll first need to ssh into your ghost blog.

ssh <user>@<your_ghost_ip>

It is now time to download the ads.txt file from AdSense or your ads provider.

Go to /var/www/ and add the ads.txt file either with vim/nano or via scp.
I strongly recommend using vim as it is faster and easier.

Once you've added the file to your /var/www, we need to redirect /ads.txt to the file. In order to do that, we'll need to change the Nginx configuration of your website.

cd /etc/nginx/sites-enabled

Find the configuration for your ghost instance and add the following location.

location ~ ^/ads.txt {
  root /var/www;
}

Once you've added the following lines in your configuration you need to restart your Nginx service.

To do so:

# Checks if the config is ok
sudo nginx -t 

# Restart the service if nginx -t is ok
sudo service nginx restart 

Now you'll be able to access your ads.txt at the root URL. For example, you can find mine at https://primates.dev/ads.txt

You'll probably need to refresh you cache or change your browser to see the changes. If you can't seem to see the changes just run the following command in your terminal.

curl https://<your_website>/ads.txt

In a few lines of codes, you'll be able to add the ads.txt file easily on your Ghost blog. Take the time to do it, and you'll increase your revenue. I hope this has been helpful. If you have any questions, please let me know below in the comments, and I'll be happy to help you improve your Ghost blog.

Bonus part  -> Install another Ghost Blog on the same instance

Happy Writing!

Ads

Stanislas Girard

Creator of Primates & Author. Devops, Blockchain, Data, Security, Machine Learning, Web ... The World is full of interesting subjects.