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.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://bitfrit.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.