Google adsense ads.txt

How Can I add ads.txt to my glitch project?

Hey @brubruninho2002,

  1. Click on the ‘New File’ button at the top of the side bar.
  2. Type the file name. In this case, it is ads.txt.
  3. Click on ‘Add File’ and the file gets created and you’re done!
    git sh – theradbot

Hope this helps!

I already tried that,seems that this doesn’t work,like Google adsense said I need to create a ads.txt file with access to the root level

Adding files to the main file tree is the root level of the Glitch project.

Hm… I tried that,dunno what to do then.

How do you know that it did not work? :thinking: Any sort of errors?

Cause this file is on my project since last 2 months and I get this message everytime I login

image

I see…:frowning: :thinking:

Put it into views folder where should be everything like html

Placing it in a folder doesn’t work, because the .txt file is needed at root level.

2 Likes

You might need to wait a little while before the Google bot scans your website again. Maybe there is an option to scan the website manually?

It should need to be handled by server.js.

Is it using express? in that case

app.get("/ads.txt", function(request, response) {
    // output processing
}

It is the same idea as robots.txt and favicon.ico.

1 Like

Also, glitch.me is registered in the Public Suffix List:
https://support.google.com/admanager/answer/9422161
https://publicsuffix.org/

Therefore, if you treat project.glitch.me as a subdomain, it may not recognize it.

Hey @brubruninho2002, if you’re using Express in server.js, can you check to see if the server.js file has a line that looks like this?

app.use(express.static("public"));

:point_up_2: This will serve the files in your /public directory as static resources, so you should place the ads.txt file in there. To confirm that it’s working, you should be able to see the contents of the ads.txt file just by visiting https://www.cloudlist.xyz/ads.txt in your browser.

Hope this helps!

Yep I am Using that already

app.set("view engine", "ejs");
    // Set the view engine to ejs (Doesn't really matter for the library though.)
    app.use(cookies()); // Setup the cookies for storing session variables
    app.use(express.static("public"));
    app.use(bodyParser.urlencoded({ extended: false }));
    app.use(express.json());

Great! And did you try moving ads.txt into your /public folder yet?

That should resolve the issue.

1 Like

Oof That was it,thank you. I am so dumb,sorry for that. Thanks <3

There’s no need to apologize, @brubruninho2002, this stuff can be hard to figure out! You’re doing great and we’re rooting for you. :tada:

3 Likes