2

I'd like to add Google AdSense to my GitHub Pages website.

Problem:

AdSense scans the root page (<user>.github.io). But I can only edit a repository page (<user>.github.io/<repo>). So the root will always return 404, making it non-eligible for AdSense.

Possible Solutions:

I can see 3 possible solutions:

  1. Use my own domain. (I know that would work, but I don't want a domain for that)
  2. Somehow edit my root Github page <user>.github.io
  3. Setup AdSense to ignore my root and scan my sub-repo.

Question:

Is any of options 2 or 3 feasible? How?

Andre Goulart
  • 528
  • 2
  • 20
  • This is related to https://stackoverflow.com/questions/69122589/how-to-make-google-auto-ads-work-with-react-ssr-application/69154282, You could use DFP to serve ads in subdomain. – Niresh Sep 19 '21 at 17:06

1 Answers1

0

Your option 2 is definitely possible.

Steps:

  1. Create a repository with the name: <user>.github.io
  2. Enable GitHub Pages for that repository
  3. Put whatever site content in that repository.
  4. It's URL will be (assuming you enable https): https://<user>.github.io

As you already discovered, if GitHub Pages is enabled on a repository with any other name, the URL will be: https://<user>.github.io/<repository>. Those are basically project sites, whereas you are looking for a user site.