I put off adding ads.txt to my site for weeks. It sounded like an advertising thing, and I was still busy making the downloader itself work. Then I applied for AdSense, and the dashboard started nagging me about a missing ads.txt file. That is when I learned it is a five-minute job I should have done on day one.

What ads.txt actually is

ads.txt is a plain text file that sits at the root of your site, at yourdomain.com/ads.txt. It lists the advertising networks that are allowed to sell your ad space. Each line looks like this:

google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0 

That line says: Google can sell ads on this site directly, and this is the publisher account it belongs to. The last bit, f08c47fec0942fa0, is a fixed tag for Google — it is the same for everyone, not a secret.

The point of the file is trust. When an advertiser buys space on your site, they can check ads.txt and confirm the seller is really you and not someone pretending to be you. If the file is missing, some ad networks simply will not serve ads, or will serve them at lower rates. That is why AdSense nags about it.

Making the file

On a plain PHP site there is nothing to install. I created a file called ads.txt and put in it the one line AdSense gave me, with my real publisher ID in place of the zeroes above. That is the whole file. If you work with more than one ad network, you add one line per network — each one gives you its own line to copy.

Then I uploaded it to the root of the site, next to index.php, using the same SFTP upload I use for everything else. The path matters: it has to be at yourdomain.com/ads.txt, not in a subfolder. If it lives at /blog/ads.txt or anywhere else, crawlers will not find it.

Checking it actually works

This is the step people skip, and it is the one that bit me. My first upload looked fine in the file manager, but I had typed the publisher ID with a typo. AdSense kept complaining, and I assumed the file was not being served at all.

So I checked it properly. First I opened https://ramrom.io/ads.txt in the browser and read the line with my own eyes. Then I ran curl from the terminal:

curl -s https://ramrom.io/ads.txt 

The output matched the line exactly. Two checks, thirty seconds, and I knew the file was live and correct. If curl returns a 404 or a hosting placeholder page, the file is in the wrong folder or the upload did not go through.

A couple of gotchas I hit along the way:

  • Mind the case. The file must be ads.txt, lowercase. Ads.txt will not be found.
  • Watch for a trailing space. A stray space after the publisher ID is easy to miss and hard to debug. I copy the line straight from the ad network and do not retype it.
  • Do not put it behind any redirect. The file should answer with a plain 200 at the root URL. If your .htaccess forces HTTPS or www, that is fine — a redirect to the same path is normal — but the final destination has to serve the file.

Why I bother saying this at all

There is nothing clever here, and that is the point. A lot of building a small site is like this: a tiny file, five minutes of work, and weeks of delay because it sounds like someone else's problem. I lost time to it because I kept telling myself the downloader was the real work and the admin files could wait. But the downloader only earns anything if the ad setup around it is complete.

If you are building a tool site on shared hosting, add ads.txt the same day you add your privacy policy. It costs nothing, takes minutes, and one day a dashboard will stop nagging you about it.