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

July 08, 2019

If you have a site built on Gatsby.js and have received a notification that you need to add an ads.txt file to the root of the site, this is how to add it:

  1. Log into AdSense
  2. Click Fix Now on the banner at the top telling you to add an ads.txt file, then click the Download link to download the ads.txt file 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 the ads.txt file 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.txt file in a browser and see its contents. Example:
  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.

Kellen Mace

Written by Kellen Mace, who lives in Rochester Hills, MI and builds cool stuff on the web. About Kellen // Follow him on Twitter →