| | |

GitHub Pages 01 ๐Ÿ“„ Introduction & Site Types โ€” Creating user, organization, project sites, and understanding public vs. private access

โฑ๏ธ Estimated read: 14 min | |

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:

  1. The root of any branch (commonly main).
  2. A specific folder named /docs on any branch.
  3. A dedicated branch named gh-pages.
  4. 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

FeatureUser SiteOrganization SiteProject Site
Repository Nameusername.github.ioorgname.github.ioAny name
Site URLusername.github.io/orgname.github.io/user.github.io/repo/
Limit1 per account1 per organizationUnlimited
Source Branchmain (usually)main (usually)Any branch, /docs, or gh-pages

URL Logic

ScenarioRepository NameResulting URL
User Account alicealice.github.iohttps://alice.github.io
Org Account devcorpdevcorp.github.iohttps://devcorp.github.io
Project in aliceportfoliohttps://alice.github.io/portfolio
Project in devcorpapi-docshttps://devcorp.github.io/api-docs

Visibility and Permissions

Repository TypeGitHub PlanSite Visibility
PublicFree / ProPublic
PrivateFreeNot Available
PrivatePro / TeamPublic (unless Enterprise)
PrivateEnterprisePrivate (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

PitfallWhy It HappensFix
404 Error on User SiteRepo name isn’t exactly username.github.ioRename the repository to match your username exactly.
Broken CSS/ImagesUsing absolute paths (/img.png) in project sitesUse relative paths (./img.png) or the full URL.
Site not updatingPush didn’t trigger build or cache issueCheck ‘Actions’ tab for build errors; use a hard refresh.
/docs folder not workingFolder isn’t in the root or branch not setEnsure /docs is at the top level and source is set in Settings.
Private repo site visibleMisunderstanding of ‘Private’ PagesUpgrade to Enterprise for authentication; otherwise, site is public.
Jekyll build failureMissing _config.yml or invalid Ruby syntaxAdd 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

ItemValue
User Site URLhttps://<username>.github.io
Project Site URLhttps://<username>.github.io/<repo-name>
User Site Repo NameMust be <username>.github.io
Supported ContentStatic files (HTML, CSS, JS, Images)
Server-Side CodeNot supported (No PHP, Ruby, etc.)
Default Build EngineJekyll
Custom DeploymentGitHub Actions
HTTPS SupportAvailable and encouraged
Custom DomainsSupported for all site types
Private ReposRequires Pro/Team/Enterprise plan
Access ControlExclusive to GitHub Enterprise

Key takeaways:

  • Naming is everything for User sites. A repository not named exactly username.github.io will 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 /docs folder 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.

Was this helpful?


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!