Git Notes
GitHub Pages is a free hosting service that turns your GitHub repository into a live website. It serves static content directly from your repository, making...
GitHub Pages is a free hosting service that turns your GitHub repository into a live website. It serves static content directly from your repository, making it the simplest way to publish documentation, portfolios, project landing pages, and blogs without paying for hosting or managing servers. Every GitHub user and organization gets access to this service automatically.
How GitHub Pages Works
GitHub Pages takes HTML, CSS, and JavaScript files from a specific branch or folder in your repository and serves them as a website. There is no server-side processing — no PHP, no database queries, no Node.js runtime. The files are served exactly as they exist in your repository, distributed globally through GitHub's CDN for fast load times.
Every time you push changes to the configured source branch, GitHub Pages automatically rebuilds and redeploys your site within minutes.
Types of GitHub Pages Sites
User/Organization Sites
Each GitHub account gets one site at username.github.io:
- Repository must be named exactly
username.github.io - Content is served from the
mainbranch root - URL:
https://username.github.io
This is ideal for personal portfolios or organization home pages.
Project Sites
Every repository can have its own GitHub Pages site:
- Content served from a branch (
mainorgh-pages) or the/docsfolder - URL:
https://username.github.io/repository-name - No special repository naming required
Setting Up GitHub Pages
From Repository Settings
- Navigate to Settings → Pages
- Under "Build and deployment," select your source:
- Deploy from a branch — Choose branch and folder
- GitHub Actions — Use a custom build workflow
- Save and wait for deployment
Quick Start with HTML
Create an index.html in your repository:
<!DOCTYPE html>
<html>
<head>
<title>My Project</title>
<style>
body { font-family: system-ui; max-width: 800px; margin: 0 auto; padding: 2rem; }
h1 { color: #2d3748; }
</style>
</head>
<body>
<h1>Welcome to My Project</h1>
<p>This site is hosted on GitHub Pages.</p>
</body>
</html>Push it to main, enable Pages, and your site is live.
Jekyll Integration
GitHub Pages has built-in support for Jekyll, a static site generator written in Ruby. You do not need to install anything locally — GitHub builds Jekyll sites automatically.
Create a minimal Jekyll site:
_config.yml:
title: My Tech Blog
description: Writing about software development
theme: minimaindex.md:
Welcome to my blog about software development.GitHub automatically builds this into a full website with navigation, styling, and a blog feed.
Using Custom Themes
Apply a Jekyll theme without any local setup:
# _config.yml
remote_theme: pages-themes/cayman@v0.2.0
title: My DocumentationPopular themes: Cayman, Minimal, Architect, Slate, Midnight.
Deploying Framework Sites (React, Vue, etc.)
For sites built with modern frameworks, use GitHub Actions:
Custom Domains
Replace username.github.io with your own domain:
- Add a
CNAMEfile to your repository containing your domain name - Configure DNS at your domain registrar:
For www.yourdomain.com:
For apex domain (yourdomain.com):
| A @ | 185.199.108.153 |
| A @ | 185.199.109.153 |
| A @ | 185.199.110.153 |
| A @ | 185.199.111.153 |
- Enable "Enforce HTTPS" in repository settings — GitHub provides free SSL
Common Use Cases
Developer portfolio: Showcase your projects, skills, and experience at yourname.github.io.
Project documentation: Host API docs, user guides, and tutorials alongside your code.
Technical blog: Write posts in Markdown, let Jekyll or a framework generate the site.
Event or organization pages: Landing pages for meetups, conferences, or community groups.
Limitations
- Static content only (no server-side code execution)
- Repositories must be under 1 GB
- Sites have a soft bandwidth limit of 100 GB per month
- Build time limited to 10 minutes
- No private Pages on free accounts (public repositories only for free tier)
Key Takeaways
GitHub Pages provides free, automatic hosting for static websites tied directly to your repository. It supports everything from simple HTML files to Jekyll-generated blogs to framework-built applications deployed via GitHub Actions. Custom domains and HTTPS come free, making it a complete hosting solution for documentation, portfolios, and any project that produces static output.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for GitHub Pages.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Git & GitHub topic.
Search Terms
git-github, git & github, git, github, fundamentals, pages, github pages
Related Git & GitHub Topics