GitHub Pages Deployment: Hosting Your Static Site for Beginners
Learn how to use GitHub Pages for deployment. We’ll show you how to host a static site directly from your repository with simple, actionable steps.

Previously in this course, we covered Advanced Branching Patterns to manage complex development cycles. Now that your project is stable and versioned, it’s time to share it with the world.
In this lesson, we are moving from local development to public hosting. You will learn how to use GitHub Pages to turn your repository into a live website, making your project accessible to anyone with a browser.
What is GitHub Pages?
GitHub Pages is a static site hosting service that takes files directly from your repository, builds them (if necessary), and serves them as a website. It is designed specifically for hosting documentation, personal portfolios, or simple project websites.
Because it serves static files—HTML, CSS, and JavaScript—you don't need a backend server, a database, or complex infrastructure. If you've been following our Project Setup Strategy, you likely already have the necessary assets to deploy your first site.
Enabling GitHub Pages
To host your site, you need to point GitHub to the files it should serve. Follow these steps to enable the service:
- Navigate to your repository on GitHub.
- Click the Settings tab in the top navigation bar.
- On the left-hand sidebar, find the Pages section under "Code and automation."
- Under Build and deployment, ensure the source is set to "Deploy from a branch."
- Select the branch you want to serve (usually
mainormaster) and the folder (usually/ (root)). - Click Save.
Once saved, GitHub will automatically trigger a build process. You can monitor the progress under the "Actions" tab in your repository. After a few minutes, a link to your live site will appear at the top of the Pages settings page.
Deploying a Static Site: A Worked Example
Let’s assume your project repository contains an index.html file in the root directory. To make this your landing page, ensure your file structure looks like this:
TEXT/my-project ├── .git/ ├── index.html ├── style.css └── README.md
- Commit your files: Ensure your
index.htmlandstyle.cssare committed to yourmainbranch. - Push to GitHub: Use
git push origin mainto sync your local work with the remote repository. - Configure Pages: Follow the steps in the previous section to set the
mainbranch as the source. - Verify: GitHub will generate a URL in the format
https://<username>.github.io/<repository-name>/. Visit this link to see your site live.
If your project requires more advanced build steps, you might explore Mastering Static Site Generation (SSG) in Next.js, but for now, keeping it simple with plain HTML is the perfect way to master the basics of deployment.
Hands-on Exercise
To practice, create a new folder named website in your project, add a simple index.html file inside it, and push it to your repository. Configure GitHub Pages to serve your site from the root directory. Once the deployment succeeds, click the provided link to view your page.
Common Pitfalls
- The 404 Error: If your site returns a 404, double-check that your entry file is named
index.html(all lowercase) and that it is located in the root of the branch you selected. - Missing Assets: If your images or CSS files aren't loading, verify your file paths. Use relative paths (e.g.,
src="images/logo.png") rather than absolute paths (e.g.,src="/images/logo.png") to ensure they resolve correctly once deployed. - Case Sensitivity: Unlike some local Windows environments, GitHub's servers are case-sensitive. If your file is
Index.htmlbut your link saysindex.html, it will fail. Always use lowercase for filenames.
FAQ
Can I use a custom domain?
Yes. In the GitHub Pages settings, there is a "Custom domain" field. You can point your own domain name (like www.yourname.com) to your GitHub Pages site by updating your DNS records.
Is there a cost for GitHub Pages? No, it is free for public repositories.
Can I host a backend (like Node.js or Python) on GitHub Pages? No. GitHub Pages is strictly for static content. If your project grows to require a server, you'll need to look into services like those discussed in Deploying a Static Frontend: Hosting and CDN Integration.
Recap
In this lesson, we enabled GitHub Pages and deployed a static site directly from a repository. You now know how to configure a build source and verify your live URL. This is a fundamental skill for showing off your work or publishing documentation, and it serves as the foundation for the more advanced Production Deployment: Automating Secure CD Pipelines techniques we will cover later in the course.
Up next: Analyzing Repository Health — we'll look at how to track visitor traffic and contributor activity to understand the impact of your project.
Work with me

CI/CD Pipeline & Docker Containerization
Ship with confidence: automated CI/CD pipelines and Docker setups so every push is tested and deployed — no more manual, error-prone releases.

VPS Server Setup, Deployment & Hardening
Get your app live on a fast, secure server — properly configured, hardened, and deployment-ready. No more wrestling with the command line.


