How to Host a Website for Free on GitHub Pages with Custom Domain in 2026
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.

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
- Log into your GitHub account and click New Repository.
- Name your repository (e.g., 'my-portfolio').
- Set the repository visibility to Public (GitHub Pages is free for public repositories; private repositories require GitHub Pro).
- Check Add a README file and click Create repository.
- Upload your 'index.html', 'style.css', and images into the root of the repository.
Step 2: Enable GitHub Pages
- In your repository, click the Settings tab.
- In the left sidebar, click Pages.
- Under Build and deployment > Source, select Deploy from a branch.
- Set the branch to 'main' (or 'master') and directory to '/ (root)'.
- Click Save. Within 60 seconds, your site will be live at 'https://username.github.io/my-portfolio/'.
Step 3: Connecting Your Custom Domain
- In the GitHub Pages settings menu, scroll down to Custom domain.
- Type your domain name (e.g., 'www.yourdomain.com') and click Save. GitHub will automatically create a 'CNAME' file in your repository.
- Log into your domain registrar (Namecheap, Porkbun, GoDaddy) and add these DNS records:
For 'www.yourdomain.com' (Recommended):
- 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.

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.


