How to Host a Website on GitHub (Beginner Friendly Guide)
Hosting a website doesn’t always require paid servers. If you are a beginner or a developer who wants to showcase projects, GitHub Pages is one of the best free options available. In this guide, you’ll learn how to host a website on GitHub step by step.
What Is GitHub?
GitHub is a popular platform used by developers to store, manage, and share code using Git version control. It also provides a free feature called GitHub Pages, which allows you to host static websites at no cost.
What Is GitHub Pages?
GitHub Pages is a free hosting service provided by GitHub to host static websites such as HTML, CSS, and JavaScript files. It does not support backend languages like PHP or databases.
Requirements Before Hosting
Before starting, make sure you have:
- A GitHub account
- A basic website with HTML, CSS, or JavaScript
- Internet connection
- A web browser
Step 1: Create a GitHub Account
- Go to https://github.com
- Click on Sign up
- Create your account using email
- Verify your email address
Step 2: Create a New Repository
- After logging in, click New Repository
- Repository name must be:
username.github.io
(Replace username with your GitHub username) - Set repository to Public
- Select Add a README file
- Click Create repository
Step 3: Upload Website Files
- Open your repository
- Click Add file → Upload files
- Upload your website files:
- index.html
- style.css
- script.js (if available)
- Click Commit changes
Important: Your homepage file must be named index.html
Step 4: Enable GitHub Pages
- Go to Repository Settings
- Click on Pages
- Under Source, select:
Branch: main
Folder: /root - Click Save
Step 5: Access Your Website
After a few minutes, your website will be live at:
https://username.github.io
Replace username with your GitHub username.
Using a Custom Domain (Optional)
You can use a custom domain by:
- Purchasing a domain from a domain provider
- Adding the domain in GitHub Pages settings
- Updating DNS records
Advantages of GitHub Pages
- Free hosting
- No advertisements
- HTTPS security
- Fast loading speed
- Perfect for portfolios and project demos
Limitations of GitHub Pages
- Backend languages are not supported
- Only static websites can be hosted
- No database support
Who Should Use GitHub Pages?
GitHub Pages is suitable for beginners, students, developers, and anyone who wants to host a simple website for free.
Final Thoughts
GitHub Pages is one of the easiest and most reliable ways to host a website without spending money. It is highly recommended for beginners learning web development.