GitHub Pages 01 ๐ Introduction & Site Types โ Creating user, organization, project sites, and understanding public vs. private access
GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files directly from a repository on GitHub, optionally runs the files through a build process, and publishes a website. It is designed to host personal, organization, or project pages. By integrating hosting directly into the version control workflow, GitHub Pages eliminates the need for separate hosting providers, FTP uploads, or complex deployment pipelines for static content.
This service is fundamentally different from traditional web hosting because it is “static-only.” It does not support server-side languages like PHP, Ruby on Rails, or Python, nor does it provide a database. Instead, it serves pre-rendered content to the browser. While it began as a way to host simple project documentation, it has evolved into a robust platform for portfolios, blogs, and documentation sites, powered by built-in Jekyll support or custom GitHub Actions workflows.
In this chapter, we explore the architecture of GitHub Pages, the distinction between user, organization, and project sites, and the security implications of public versus private access. We will cover how naming conventions dictate the final URL and how GitHub determines which files to serve based on the repository’s configuration.
Key point: GitHub Pages converts GitHub repositories into live websites, using specific repository naming conventions for User/Org sites and branch-based configurations for Project sites. It is a static-site solution that relies on Git workflows for content updates and deployment.
Why X exists
The deployment friction problem. Historically, hosting a website required a separate server, an FTP client, and a manual process of moving files. If a developer updated their code on GitHub, they would have to remember to update the hosted site separately. GitHub Pages exists to solve this by making “git push” the deployment mechanism. When code hits the repository, the site updates automatically.
The documentation hosting problem. Open-source software lives or dies by its documentation. Before GitHub Pages, developers struggled to find a consistent place to host READMEs, API references, and tutorials that stayed in sync with the current code version. GitHub Pages allows documentation to live inside the same repository as the source code, ensuring that the manual or guide always matches the branch being used.
The static site revolution. As frontend frameworks like React, Vue, and static site generators like Jekyll and Hugo grew in popularity, the need for complex server-side backends for content delivery decreased. GitHub Pages provides the ideal environment for these modern static architectures, offering high availability and global CDN delivery for free or at a very low cost compared to managed servers.
The “username branding” problem. Developers often need a centralized home on the web that reflects their professional identity. By providing the username.github.io domain, GitHub gave every developer a standardized, professional-looking URL that is immediately recognizable to the tech community. This helps in building a portfolio that is directly linked to oneโs contributions and code history.
The trade-off. The primary trade-off of GitHub Pages is the lack of dynamic server-side processing. Because GitHub Pages only serves static files, developers must move dynamic logic to the client-side (JavaScript) or use third-party APIs for functions like form handling, comments, or search. This trade-off results in significantly higher security, as there is no server-side database to breach or script to exploit on the host’s end.
a. User and Organization Sites
User and Organization sites are “primary” sites associated with a specific GitHub account. Each account (user or organization) is limited to exactly one primary site. These sites are unique because they are hosted at the root of the github.io subdomain assigned to the account. For example, if your username is octocat, your site will be https://octocat.github.io.
To create a User site, you must create a repository named exactly <username>.github.io. The “username” part must match your GitHub account name perfectly, including case sensitivity in some contexts, though GitHub generally handles the URL routing case-insensitively. For an organization named dev-corp, the repository must be dev-corp.github.io.
# Steps for User Site Repository
1. Name: user123.github.io
2. Visibility: Public (usually)
3. Content: index.html at the root
Unlike Project sites, User/Org sites traditionally required the content to be on the main (or formerly master) branch. While GitHub has recently allowed more flexibility via GitHub Actions, the standard convention for a simple User site remains the root of the default branch. This repository’s sole purpose is usually to host the personal landing page or the organization’s main homepage.
When you push to this repository, GitHub automatically triggers a build process. By default, it looks for an index.html, index.md, or a Jekyll configuration. If you use a custom domain, it will replace the github.io address, but the repository naming convention remains the trigger that tells GitHub “this is the primary site for this account.”
b. Project Sites
Project sites are associated with a specific repository that isn’t the primary User/Org site. An account can have an unlimited number of Project sites. The URL for a project site follows a path-based structure: https://<username>.github.io/<project-repo>/. If you have a repository named weather-app, the site would live at https://octocat.github.io/weather-app/.
Project sites offer more flexibility in terms of “Source.” You can configure GitHub to publish the site from:
- The root of any branch (commonly
main). - A specific folder named
/docson any branch. - A dedicated branch named
gh-pages. - A custom GitHub Actions workflow.
# Project Site Configuration Options
- Branch: main / Folder: (root)
- Branch: main / Folder: /docs
- Branch: gh-pages / Folder: (root)
The /docs folder option is particularly popular for library maintainers. It allows the source code to live in the root and /src directories, while the documentationโoften generated by tools like Doxygen or TypeDocโlives in the /docs folder within the same branch. This keeps the documentation tightly coupled with the code version it describes.
The gh-pages branch is a legacy convention that is still widely supported. It is an “orphan” branch (a branch with no parent history) that contains only the build artifacts (minified JS, optimized CSS, HTML) of the application. This is useful when the source code requires a complex build step (like a React or Vue app) and you only want to deploy the dist or build folder without cluttering the main source branch with generated files.
c. Public vs. Private Access
The visibility of your GitHub Pages site is intrinsically linked to the visibility of the repository and your GitHub plan. Historically, GitHub Pages sites were always public. If the repository was public, the site was public. Even if a repository was private, once GitHub Pages was enabled (on paid plans), the resulting URL was accessible to anyone who had the link.
For GitHub Free users, GitHub Pages is only available for Public repositories. If you want to host a site from a Private repository, you must upgrade to GitHub Pro, GitHub Team, or GitHub Enterprise.
# Access Matrix
- GitHub Free: Public Repos only -> Public Site
- GitHub Pro/Team: Private Repos -> Public Site (by default)
- GitHub Enterprise: Private Repos -> Private/Public Site options
In GitHub Enterprise environments, “Private Pages” (Access Control) is a critical feature. It allows organizations to host internal documentation, dashboards, or project status pages that are only viewable by authenticated members of the organization. When a user navigates to a private GitHub Pages URL, they are prompted to log in via GitHub. If they do not have read access to the underlying repository, they cannot see the site.
It is a common security pitfall to assume that hosting from a private repository on a standard Pro/Team account makes the website private. It does not. The source code is private, but the published site is public at the github.io URL unless you are using GitHub Enterprise Cloud with “Access Control” enabled. Always treat a GitHub Pages URL as a public endpoint unless you have specifically configured IP whitelisting or SSO-backed access control in an Enterprise environment.
Complete Example Session
# ============================================
# PART 1: CREATING THE USER SITE REPO
# ============================================
# Log into GitHub CLI and create the primary site repository
# Replace 'username' with your actual GitHub username
gh repo create username.github.io --public --clone
# ============================================
# PART 2: INITIALIZING THE HOME PAGE
# ============================================
cd username.github.io
echo "<h1>Welcome to My GitHub Page</h1>" > index.html
echo "<p>This is my user-level site.</p>" >> index.html
# ============================================
# PART 3: DEPLOYING THE USER SITE
# ============================================
git add index.html
git commit -m "Initial commit for user site"
git push origin main
# ============================================
# PART 4: CREATING A PROJECT SITE REPO
# ============================================
cd ..
mkdir my-project-app
cd my-project-app
git init
echo "<h1>Project Specific Site</h1>" > index.html
gh repo create my-project-app --public --source=. --remote=origin
# ============================================
# PART 5: CONFIGURING PROJECT SITE SOURCE
# ============================================
# By default, GitHub might not enable Pages for a new repo.
# We push first, then we would enable it in Settings > Pages.
git add .
git commit -m "Add project index"
git push -u origin main
# ============================================
# PART 6: USING THE /docs FOLDER APPROACH
# ============================================
mkdir docs
echo "<h1>Documentation Root</h1>" > docs/index.html
git add docs/
git commit -m "Add documentation folder"
git push
# ============================================
# PART 7: VERIFYING DEPLOYMENT STATUS
# ============================================
# Check the deployment status via CLI
gh run list --workflow "pages-build-deployment"
# ============================================
# PART 8: SETTING UP A GH-PAGES BRANCH
# ============================================
# Create a separate branch for deployment only
git checkout --orphan gh-pages
git rm -rf .
echo "<h1>Site from gh-pages branch</h1>" > index.html
git add index.html
git commit -m "Deploy to gh-pages"
git push origin gh-pages
# ============================================
# PART 9: CHECKING URL STRUCTURES
# ============================================
# User Site: https://username.github.io
# Project Site: https://username.github.io/my-project-app
# ============================================
# PART 10: CLEANUP (Optional)
# ============================================
# git checkout main
The parts above demonstrated the creation of a User site, the setup of a Project site using both the root directory and the /docs folder, the creation of a standalone gh-pages branch, and the verification of the deployment through the GitHub environment.
Quick Reference
Site Type Comparisons
| Feature | User Site | Organization Site | Project Site |
|---|---|---|---|
| Repository Name | username.github.io | orgname.github.io | Any name |
| Site URL | username.github.io/ | orgname.github.io/ | user.github.io/repo/ |
| Limit | 1 per account | 1 per organization | Unlimited |
| Source Branch | main (usually) | main (usually) | Any branch, /docs, or gh-pages |
URL Logic
| Scenario | Repository Name | Resulting URL |
|---|---|---|
User Account alice | alice.github.io | https://alice.github.io |
Org Account devcorp | devcorp.github.io | https://devcorp.github.io |
Project in alice | portfolio | https://alice.github.io/portfolio |
Project in devcorp | api-docs | https://devcorp.github.io/api-docs |
Visibility and Permissions
| Repository Type | GitHub Plan | Site Visibility |
|---|---|---|
| Public | Free / Pro | Public |
| Private | Free | Not Available |
| Private | Pro / Team | Public (unless Enterprise) |
| Private | Enterprise | Private (Access Control) |
Best Practices
โ Do This:
# Use lowercase for repository names to avoid URL confusion // โ
# Keep index.html in the root or /docs folder // โ
# Use a custom 404.html for better user experience // โ
# Leverage GitHub Actions for complex build steps // โ
# Check "Enforce HTTPS" in the repository settings // โ
# Use relative paths for assets in Project sites (./css/...) // โ
โ Don’t Do This:
# Name a user site repo 'my-site.github.io' (must be username) // โ
# Upload sensitive data (.env, keys) to the repo // โ
# Expect PHP or Node.js server code to run on Pages // โ
# Use absolute root paths (/style.css) for project sites // โ
# Name your project repo exactly like your user repo // โ
# Ignore the build logs in the 'Actions' tab // โ
Common Pitfalls
| Pitfall | Why It Happens | Fix |
|---|---|---|
| 404 Error on User Site | Repo name isn’t exactly username.github.io | Rename the repository to match your username exactly. |
| Broken CSS/Images | Using absolute paths (/img.png) in project sites | Use relative paths (./img.png) or the full URL. |
| Site not updating | Push didn’t trigger build or cache issue | Check ‘Actions’ tab for build errors; use a hard refresh. |
| /docs folder not working | Folder isn’t in the root or branch not set | Ensure /docs is at the top level and source is set in Settings. |
| Private repo site visible | Misunderstanding of ‘Private’ Pages | Upgrade to Enterprise for authentication; otherwise, site is public. |
| Jekyll build failure | Missing _config.yml or invalid Ruby syntax | Add a .nojekyll file to bypass Jekyll if not needed. |
Real-World Examples
1. Simple User Portfolio
A repository named janesmith.github.io containing an index.html and a styles.css file.
2. Technical Documentation
A project named fast-api-wrapper using the /docs folder to host a Docusaurus-generated site.
3. React App Deployment
A project using a GitHub Action to build the React code and push the build/ contents to the gh-pages branch.
4. Organization Landing Page
google.github.io hosting a list of all open-source projects maintained by Google.
5. Project Blog
A repository named dev-blog using Jekyll to convert Markdown files in _posts/ into a blog at user.github.io/dev-blog.
6. Resume Page
A single index.html file in a repo named resume hosted at username.github.io/resume.
7. Internal Team Wiki
An Enterprise-level private repository with Access Control enabled for internal documentation.
8. Project Changelog
A simple HTML file tracking version history for a desktop application, hosted on GitHub Pages for easy access.
9. CSS Framework Demo
A project showing interactive components of a new CSS library, allowing developers to see the code in action.
10. Slide Deck
Hosting an HTML-based slideshow (using Reveal.js) for a conference talk at speaker.github.io/talk-title.
Visual
User vs. Project Site Hierarchy
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GITHUB ACCOUNT: "dev-user" โ
โ โ
โ REPOS: โ
โ 1. dev-user.github.io โโโโบ USER SITE (Root) โ
โ URL: https://dev-user.github.io โ
โ โ
โ 2. weather-app โโโโบ PROJECT SITE (Path) โ
โ URL: https://dev-user.github.io/app โ
โ โ
โ 3. personal-blog โโโโบ PROJECT SITE (Path) โ
โ URL: https://dev-user.github.io/blogโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Project Site Source Logic
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ REPOSITORY STRUCTURE OPTIONS โ
โ โ
โ [ Option A: Root ] [ Option B: /docs ] [ Option C: gh-pages ]
โ ๐ main branch ๐ main branch ๐ gh-pages branch โ
โ โโโ index.html โโโ โโโ src/ โโโ index.html โโโ โ
โ โโโ style.css โ โโโ docs/ โโโ static/ โ โ
โ โโโ script.js โ โ โโโ index.html โโโ โ โ
โ โ โโโ package.json โ โ โ
โ (Published)โโโโ (Published)โโโโโโโ (Published)โโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The Deployment Pipeline
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DEPLOYMENT WORKFLOW โ
โ โ
โ 1. [ Local Dev ] โโโบ git push โโโบ 2. [ GitHub Repo ] โ
โ โ โ
โ 4. [ Live Site ] โโโ Global CDN โโโ 3. [ Pages Build Engine ] โ
โ โ โ
โ - Site is served - Assets cached - Jekyll/Actions run โ
โ - SSL (HTTPS) - Fast loading - HTML generated โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Summary
| Item | Value |
|---|---|
| User Site URL | https://<username>.github.io |
| Project Site URL | https://<username>.github.io/<repo-name> |
| User Site Repo Name | Must be <username>.github.io |
| Supported Content | Static files (HTML, CSS, JS, Images) |
| Server-Side Code | Not supported (No PHP, Ruby, etc.) |
| Default Build Engine | Jekyll |
| Custom Deployment | GitHub Actions |
| HTTPS Support | Available and encouraged |
| Custom Domains | Supported for all site types |
| Private Repos | Requires Pro/Team/Enterprise plan |
| Access Control | Exclusive to GitHub Enterprise |
Key takeaways:
- Naming is everything for User sites. A repository not named exactly
username.github.iowill default to being a Project site with a sub-path URL. - Project sites are versatile. They allow you to host documentation or demos from any repository by selecting the source branch or a
/docsfolder in the repository settings. - GitHub Pages is for static content. It is excellent for portfolios and documentation but cannot host applications requiring a server-side database or runtime like Node.js or Python.
- Path awareness is crucial. Assets in Project sites often break because developers forget the site is hosted in a subdirectory (
/repo-name/) rather than the domain root. - Visibility depends on the plan. While the source code can be private on Pro plans, the published site is public to anyone with the URL unless you have Enterprise Access Control.
- Automated builds are the default. Every push to the designated source branch triggers a GitHub Action that builds and deploys the site automatically.
Remember: GitHub Pages bridges the gap between code and presentation. By treating your website as a repository, you gain all the benefits of version controlโhistory, branching, and collaborationโfor your web content. For User sites, remember the one-per-account rule and the specific repository naming requirement. For Project sites, ensure your asset paths are relative to accommodate the subdirectory URL structure.
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!