How to Restore GitHub Pages Custom Domain After Subscription Lapse

This guide documents how to restore your GitHub Pages site (dapurv5.github.io) with custom domain (vermaapurv.com) if your GitHub Pro subscription expires and your site goes down.

Problem

When GitHub Pro subscription expires:

  1. The custom domain configuration gets removed from GitHub Pages
  2. GitHub releases your claim on the custom domain
  3. Your site shows a 404 error
  4. You cannot simply re-add the custom domain - GitHub requires re-verification

Prerequisites

  • GitHub account with active subscription
  • Access to your domain registrar (Squarespace/Google Domains for vermaapurv.com)
  • GitHub CLI (gh) installed and authenticated

Step 1: Verify Domain Ownership with GitHub

1.1 Go to GitHub Account Settings

  1. Go to https://github.com/settings/pages
  2. Or: Click your profile picture → Settings → Pages (in left sidebar)

1.2 Add Domain for Verification

  1. Click “Add a domain”
  2. Enter your domain: vermaapurv.com
  3. Click “Add domain”

1.3 Copy the Verification Details

GitHub will show you:

  • Hostname: _github-pages-challenge-dapurv5.vermaapurv.com
  • TXT Record Value: A code like 145d566669f10cb2303c10d6612a72

Keep this page open - you’ll need to click “Verify” after adding the DNS record.


Step 2: Add DNS TXT Record in Squarespace (formerly Google Domains)

2.1 Access DNS Settings

  1. Go to https://domains.google.com or https://domains.squarespace.com
  2. Sign in with your Google account
  3. Click on vermaapurv.com
  4. Click DNS in the left sidebar

2.2 Add the TXT Record

  1. Scroll to “Custom records” section
  2. Click “ADD RECORD”
  3. Fill in the fields:
Field Value
Type TXT
Name _github-pages-challenge-dapurv5
TTL 1 hr (default)
TEXT The verification code from GitHub (e.g., 145d566669f10cb2303c10d6612a72)
  1. Click “SAVE”

2.3 Verify DNS Propagation

Open Terminal and run:

dig TXT _github-pages-challenge-dapurv5.vermaapurv.com +short

Wait until it returns your verification code (usually 1-5 minutes).


Step 3: Complete GitHub Verification

  1. Go back to the GitHub verification page (from Step 1.3)
  2. Click “Verify”
  3. You should see a green checkmark indicating the domain is verified

Step 4: Add Custom Domain to Repository

Option A: Via GitHub Web UI

  1. Go to your repository: https://github.com/dapurv5/dapurv5.github.io
  2. Click SettingsPages (in left sidebar)
  3. Under “Custom domain”, enter: vermaapurv.com
  4. Click “Save”

Option B: Via GitHub CLI

gh api repos/dapurv5/dapurv5.github.io/pages -X PUT -f cname="vermaapurv.com"

Step 5: Wait for HTTPS Certificate

GitHub automatically provisions an HTTPS certificate. This can take 1-15 minutes.

Check certificate status:

gh api repos/dapurv5/dapurv5.github.io/pages --jq '.https_certificate'

Wait until state shows "approved".


Step 6: Enable HTTPS Enforcement

Option A: Via GitHub Web UI

  1. Go to repository SettingsPages
  2. Check the box “Enforce HTTPS”

Option B: Via GitHub CLI

gh api repos/dapurv5/dapurv5.github.io/pages -X PUT -F https_enforced=true

Step 7: Trigger a Site Rebuild (if needed)

If the site still shows 404 after all steps:

gh api repos/dapurv5/dapurv5.github.io/pages/builds -X POST

Check build status:

gh api repos/dapurv5/dapurv5.github.io/pages/builds/latest --jq '.status'

Step 8: Clear Browser Cache

If the site still shows 404 in your browser but works via curl:

  • Hard refresh: Cmd+Shift+R (Mac) or Ctrl+Shift+R (Windows)
  • Clear site data: Chrome DevTools → Application → Storage → Clear site data
  • Incognito window: Cmd+Shift+N and visit the site

Verification Commands

Check if site is working:

curl -sI https://vermaapurv.com/ | head -5

Expected output should show HTTP/2 200.

Check GitHub Pages configuration:

gh api repos/dapurv5/dapurv5.github.io/pages

Check current DNS records:

dig A vermaapurv.com +short
dig TXT _github-pages-challenge-dapurv5.vermaapurv.com +short

Current DNS Records (for reference)

Your domain should have these records in Squarespace/Google Domains:

A Records (point to GitHub Pages)

| Type | Name | Data | |——|——|——| | A | @ | 185.199.108.153 | | A | @ | 185.199.109.153 | | A | @ | 185.199.110.153 | | A | @ | 185.199.111.153 |

CNAME Record (www subdomain)

| Type | Name | Data | |——|——|——| | CNAME | www | vermaapurv.com |

TXT Record (GitHub verification - can be removed after verification)

| Type | Name | Data | |——|——|——| | TXT | _github-pages-challenge-dapurv5 | (verification code) |


Troubleshooting

“Custom domain is already taken” error

  • You need to verify domain ownership first (Steps 1-3)
  • The verification TXT record must be added before GitHub will allow you to claim the domain

Site shows 404 but curl shows 200

  • Browser cache issue - do a hard refresh or use incognito

HTTPS not working

  • Wait for certificate provisioning (check with gh api repos/.../pages --jq '.https_certificate')
  • Make sure “Enforce HTTPS” is enabled

dapurv5.github.io not redirecting properly

  • This is expected to redirect to vermaapurv.com when custom domain is set
  • Make sure HTTPS enforcement is enabled for proper https:// redirects

File Locations

  • CNAME file: /Users/verapurv/MyCode/dapurv5.github.io/CNAME (contains vermaapurv.com)
  • This guide: /Users/verapurv/MyCode/dapurv5.github.io/GITHUB_PAGES_RECOVERY.md

Last updated: April 10, 2026