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
Fix Nowon the banner at the top telling you to add an
ads.txtfile, then click the
Downloadlink to download the
ads.txtfile 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.txtfile 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.txtfile in a browser and see its contents. Example:
- 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.