How do I upload ads.txt from Google Adsense in my domains root directory?

Hi Everyone - I am new to Netlify and new to website building in general, excited to be here!

I’ve published my website recently (freesolitaire.co) and I am having a problem uploading the ads.txt from AdSense into my root domain.

I didn’t create this website in Jekyll or any other static site generator. This game was developed and I have added onto the code to make the game into the website. I am very very new to this and any help would be much appreciated

hi there, how are you deploying your site? are you using drag n drop, or are you deploying from a git repo?

Hi Perry!

I am just dragging and dropping the file directly to Netlify.

hey lucas,

you can drag n drop an entire folder - so you could try adding the ads.txt to a folder and then dragging n dropping the whole thing.

let us know if this works - if yes, it’ll definitely help other people. :muscle:

Absolutely, I’ll give it a go! Does it matter which folder the ads.text is put into?

i’m not super familiar with where that file goes - i am assuming it goes in the document root, so, whichever folder your index.html is also in.

you might check google’s documentation if its unclear.

Updated on my end. I put the code in the folder with my index.html. When I did it this way the site launched incorrectly. Do I need to add the code directly in the index.html you think?

What google documentation are you referring to? I will read through it.

He said he’s not super familiar with it, so, you probably don’t have much luck here. You might try searching. Here’s one link I found: Ads.txt guide - Google AdSense Help. I have never used AdSense, so, I am not very knowledgeable about this topic either, but, in that link, Google says that you need to add the .txt file in your website’s root, which means, the folder in which you have your home page’s index.html. I can’t see why adding that file should break your website. Just download the file from your dashboard, copy it to your publish folder and upload the website again.

EDIT: I just went to https://freesolitaire.co/ads.txt and I got a 404. Seems like you still haven’t uploaded the required file.

Hi Hrishikesh, thank you for your help. When I follow the above instructions this is the result I am getting:

This is what my folder looks like for the site with the txt file added in:

Screen Shot 2020-10-04 at 12.22.52 PM

Why’s your index.html inside a Index folder. Technically, your website’s address now is yourdomain.com/index/. And if you’ve used relative links, it probably won’t work.

You should probably move that index.html out of the Index folder. That’s the root of your (actually most of the) website(s). If you’re using a different configuration, sorry, we probably can’t help you unless we actually see the site’s source code.

Hi,

I am in need of adding in an ads.txt file, robots.txt file and .htaccess file, I publish using Git. Can I ask how would I go about publishing the files mentioned into my root directory?

Thank you,

Hi @Route15

Welcome to the forums.

A .htaccess file serves no purpose on Netlify. What does it contain?

As for the ads.txt and robots.txt publishing these to a domain root is possible, but the process will vary depending on how the site built.

If the site is plain HTML/CSS/JS, then placing them in the directory that is published will work. If using something like React then placing the files in the public directory will see them copied to the build directory which is then deployed. Vue, Next.js, et.al. are similar.

If you have further questions or issues, do not hesitate to reply.

1 Like

Hi Coel May,

Thank you for the quick reply. I wanted to test a domain block using the .htaccess file but it’s not a must for me so I can skip this.

Regarding the ads.txt and robots.txt files I have done as of you have said and placed the files in the public directory, this has worked for my Next.js site.

Thank you very much for this, I appreciate it.

Kind regards,

Shahinoor Rahman.