Skip to main content
Website & Hosting

How to Host a Website for Free on GitHub Pages with Custom Domain in 2026

Alex MorganAlex MorganSeptember 23, 20262 min read

Disclosure: Some links in this article are affiliate links. If you click and make a purchase, we may earn a commission at no extra cost to you. This does not influence our editorial recommendations - we only recommend products and services we genuinely believe in. Read our full affiliate disclosure.

How to Host a Website for Free on GitHub Pages with Custom Domain in 2026 โ€“ featured image

If your website is built with static HTML, CSS, JavaScript, or generated via modern frameworks like Astro, Hugo, or Next.js static export, you never need to pay for web hosting.

Through GitHub Pages, Microsoft provides enterprise-grade, lightning-fast static website hosting backed by Fastly CDN infrastructure completely free forever. You can connect your own custom '.com' domain, get automated SSL encryption, and automate deployments with GitHub Actions. Here is the step-by-step tutorial.


Step 1: Create Your GitHub Repository

  1. Log into your GitHub account and click New Repository.
  2. Name your repository (e.g., 'my-portfolio').
  3. Set the repository visibility to Public (GitHub Pages is free for public repositories; private repositories require GitHub Pro).
  4. Check Add a README file and click Create repository.
  5. Upload your 'index.html', 'style.css', and images into the root of the repository.

Step 2: Enable GitHub Pages

  1. In your repository, click the Settings tab.
  2. In the left sidebar, click Pages.
  3. Under Build and deployment > Source, select Deploy from a branch.
  4. Set the branch to 'main' (or 'master') and directory to '/ (root)'.
  5. Click Save. Within 60 seconds, your site will be live at 'https://username.github.io/my-portfolio/'.

Step 3: Connecting Your Custom Domain

  1. In the GitHub Pages settings menu, scroll down to Custom domain.
  2. Type your domain name (e.g., 'www.yourdomain.com') and click Save. GitHub will automatically create a 'CNAME' file in your repository.
  3. Log into your domain registrar (Namecheap, Porkbun, GoDaddy) and add these DNS records:
  • Type: 'CNAME'
  • Host: 'www'
  • Value: 'username.github.io'

For apex root 'yourdomain.com':

  • Type: 'A' Record
  • Points to: '185.199.108.153', '185.199.109.153', '185.199.110.153', '185.199.111.153'

Step 4: Enforce HTTPS

Once your DNS propagates (usually 10 to 30 minutes), return to GitHub Pages settings and check the box "Enforce HTTPS". GitHub automatically provisions and manages a free Let's Encrypt SSL certificate for your custom domain.

#github pages#free website hosting#host website on github#custom domain github pages#2026
Alex Morgan - Founder & Lead Editor
Alex MorganยทFounder & Lead Editor

Alex Morgan is the founder and lead editor of RemoGrid. With over six years of hands-on experience in remote operations, cross-border freelance workflows, and AI tool benchmarking, Alex independently tests and audits software platforms to help modern digital workers build sustainable online income streams. He regularly reviews international payment systems (Wise, Stripe, Payoneer, local mobile wallets) and conducts real-world usability benchmarks across AI productivity tools.

Related Articles

Featured image for Best Cheap Dedicated Servers for Game Server Hosting in 2026Website & Hosting

Best Cheap Dedicated Servers for Game Server Hosting in 2026

Discover the best budget-friendly bare-metal dedicated servers for hosting Minecraft, Rust, Palworld, and ARK in 2026, comparing CPU single-core performance, anti-DDoS mitigation, and bandwidth.

#Dedicated Servers#Game Hosting
September 25, 20267 min read
Featured image for Best Object Storage for Media-Heavy Websites in 2026Website & Hosting

Best Object Storage for Media-Heavy Websites in 2026

Compare the best cloud object storage solutions for media-heavy websites in 2026. Detailed cost breakdown of Cloudflare R2, Backblaze B2, Wasabi, AWS S3, and DigitalOcean Spaces.

#Object Storage#Cloud Storage
September 25, 20266 min read
Featured image for Best WordPress Security Audit Tools & Plugins in 2026Website & Hosting

Best WordPress Security Audit Tools & Plugins in 2026

Compare the top WordPress security audit tools and plugins in 2026, including Wordfence, Solid Security, Patchstack, Sucuri, and WPScan CLI, with actionable hardening steps for every site.

#WordPress Security#Security Plugins
September 25, 20266 min read