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:
- Log into AdSense
- Click
Fix Now
on the banner at the top telling you to add anads.txt
file, then click theDownload
link to download theads.txt
file to your computer. - 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. - 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. - Commit the changes and deploy the site.
- 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:https://example.com/ads.txt
- 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 Kellen Mace, who lives in Rochester Hills, MI and builds cool stuff on the web. About Kellen // Follow him on Twitter →