How to Add an AdSense ads.txt file to a Gatsby site

May 20, 2021

How to Add an AdSense ads.txt file to a Gatsby site

If you have a site built onGatsby.js and have received a notification that you need to add anads.txtfile to the root of the site, this is how to add it:

  1. Log into AdSense
  2. ClickFix Nowon the banner at the top telling you to add anads.txtfile, then click theDownloadlink to download theads.txtfile to your computer.
  3. Open up your Gatsby project’s main folder. Create a/static/folder at the top level of your project if you don’t have one already.
  4. Drop theads.txtfile into it:/static/ads.txt. This file will be copied into your site’s/public/folder during the build process.
  5. Commit the changes and deploy the site.
  6. After the deployment finishes, check your site to confirm that you can navigate to the ads.txtfile in a browser and see its contents. Example:https://bitfrit.com/ads.txt
  7. Google’s documentation says “It may take a few days for your changes to be reflected in AdSense”, so wait a few days. Then the notifications about adding an ads.txt file should disappear, and AdSense will start referencing that file.

Written by Manoj Bhardwaj who lives and works in Dharamshala Himachal Pradesh (India). My stackoverflow