Technologies and Software Engineering

Configure Google AdSense for GitHub Pages `username.github.io` sites

Overview

Configure Google AdSense and verify **ads.txt** for GitHub Pages sites utilizing the **username.github.io** domain, specifically addressing setups without custom domains.

Key Insights

Technical Details

GitHub Pages **username.github.io** Setup

GitHub Pages typically hosts content at https://<GITHUB_USERNAME>.github.io/<REPO_NAME>/. A special convention exists for personal and organization homepages:

Google AdSense **ads.txt** Verification

Verify your site with Google AdSense by uploading an **ads.txt** file containing your publisher information to your site’s **root directory**.

  1. Create **ads.txt** File: Create a plain text file named **ads.txt**.
  2. Add Publisher ID: Insert the following line into the **ads.txt** file, replacing pub-0000000000000000 with your actual Google AdSense publisher ID:
    google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0
    
  3. Upload to **Root Directory**: Upload the **ads.txt** file to the **root directory** of your **<GITHUB_USERNAME>.github.io** repository.
    • Crucial: The file must be directly accessible at https://<GITHUB_USERNAME>.github.io/ads.txt, not within any subdirectories.
  4. Verify Accessibility: Confirm the **ads.txt** file is publicly accessible via its direct URL (e.g., https://codeadamca.github.io/ads.txt).
  5. Initiate AdSense Check: Navigate to your AdSense account’s site list and click “Check for updates” for your verified site.
  6. Verification Time: AdSense verification can take up to a few days.
Tags:

Search