Skip to content

Instantly share code, notes, and snippets.

@saranyan
Forked from chrisjacob/README.md
Created July 24, 2012 19:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save saranyan/3172161 to your computer and use it in GitHub Desktop.
Save saranyan/3172161 to your computer and use it in GitHub Desktop.
How to: GitHub Pages "gh-pages" branch for User & Organization Pages

GitHub Pages "Normal" Setup for User & Organization Pages

Let’s say your GitHub username is “alice”. If you create a GitHub repository named alice.github.com, commit a file named index.html into the master branch, and push it to GitHub, then this file will be automatically published to http://alice.github.com/... The same works for organizations.

Read more here: http://pages.github.com/

However... the downside of this is that anyone that forks this repo won't get it as a GitHub Pages repo when they are working on it... because they have a different GitHub "username" (or "organisation name").

So the trick is to not use a master branch as the documentation tells you... rather, use a gh-pages branch, as you would for your other "Project Pages".

Process

  1. Create a New Repository on GitHub (don't follow any of the suggested setup instructions).
  2. mkdir alice.github.com
  3. cd alice.github.com
  4. git init
  5. git branch -m master gh-pages <- renames the "master" branch to "gh-pages"
  6. echo "<h1>Hello Alice</h1>" > index.html
  7. git add index.html
  8. git commit -m "initial commit"
  9. git remote add origin git@github.com:alice/alice.github.com.git
  10. git push -u origin gh-pages

Bam. http://alice.github.com


I'm personally using this for my "viewsource" Organization Page... which is an open source GitHub Pages hosted CDN for popular (and less popular) JavaScript/CSS/HTML libraries and resources.

http://viewsource.github.com

@farleylai
Copy link

Hi, I followed the steps but got 404 Not Found eventually.
I have two branches src for sources and gh-pages for deployment.

In the Settings/Source section, the dropdown box is greyed out.

GitHub Pages is currently disabled. You must first add content to your repository before you can publish a GitHub Pages site.

Moreover, the branches view, the src shows github pages are successfully built with a green checkbox but not the gh-pages.

gh

Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment