How to Host a Website on GitHub Pages Free (Custom Domain Setup Included)
3 min read
1 hour ago
Published on Apr 14, 2026
This response is partially generated with the help of AI. It may contain inaccuracies.
Table of Contents
Introduction
This tutorial will guide you through the process of hosting a website on GitHub Pages for free, including how to set up a custom domain. By following these steps, you'll create a professional online presence that can impress visitors and showcase your work.
Step 1: Create a GitHub Repository
- Sign in to GitHub: If you don't have an account, create one at GitHub.
- Create a new repository:
- Click the “+” icon in the top right corner and select "New repository."
- Name your repository (e.g.,
username.github.iowhereusernameis your GitHub username). - Set the repository to public.
- Check the box for "Initialize this repository with a README."
- Click "Create repository."
Step 2: Add Files to Your Repository
-
Upload your website files:
- Navigate to your new repository.
- Click on "Add file" and select "Upload files."
- Drag and drop your HTML, CSS, and any other files into the upload area.
- Click "Commit changes" to save your files.
-
Use a template (optional):
- You can use free templates from sites like:
- Download your chosen template, then upload the files to your repository.
Step 3: Set Up GitHub Pages
- Go to repository settings:
- Click on the "Settings" tab in your repository.
- Scroll to GitHub Pages section:
- Under "Source," select the branch to use (typically
mainormaster). - Click "Save."
- Under "Source," select the branch to use (typically
- Access your website:
- Your website will be live at
https://username.github.ioafter a few minutes.
- Your website will be live at
Step 4: Set Up a Custom Domain
- Purchase a domain: Buy a custom domain from a registrar (e.g., GoDaddy, Namecheap).
- Configure DNS settings:
- Log into your domain registrar account.
- Find the DNS settings for your domain.
- Add the following records:
- A Record:
- Name:
@ - Value:
185.199.108.153
- Name:
- CNAME Record:
- Name:
www - Value:
username.github.io(replaceusernamewith your GitHub username).
- Name:
- A Record:
- Update GitHub repository settings:
- Go to your repository settings again.
- In the GitHub Pages section, enter your custom domain (e.g.,
www.yourdomain.com). - Click "Save."
Conclusion
You've successfully set up a website on GitHub Pages with a custom domain! This enhances your online presence and provides a professional touch. As next steps, consider customizing your website further, adding content, or exploring more advanced features like integrating forms or analytics. For more tips and tutorials, visit IdeaSpot.