Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github pages: Why do I need a gh-pages

I have deployed a personal blog using Github pages and I see that some tutorials tell you to create a gh-pages branch. I did that, however, my changes to the website are visible only if I make changes to my master. So, I'm confused as to why I need gh-pages? Can someone please explain this. Thanks

like image 406
user1142130 Avatar asked Mar 14 '16 03:03

user1142130


People also ask

Do you need GH-pages?

You no longer need a gh-pages branch. GitHub now allows pages to be published from the master branch , or from a docs folder in master.

What is the use of GH-pages?

GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, optionally runs the files through a build process, and publishes a website.

Do I have to use Jekyll with GitHub Pages?

So it turns out the answer is that you can use jekyll source code, but only if it's in the gh-pages branch. If you use the docs/ folder or the master branch, it seems that you need to build locally before pushing (these options just allow you to host compiled HTML files rather than the raw jekyll source files).

What is GH page branch?

git checkout gh-pages means you've switched to the branch named 'gh-pages'. Any change you commit to this branch is picked up by github to build your github pages. To switch back to the 'master' branch (presumably your source code), do git checkout master .


3 Answers

You no longer need a gh-pages branch. GitHub now allows pages to be published from the master branch, or from a docs folder in master.

Now you can select a source in your repository settings and GitHub Pages will look for your content there.

like image 113
Dan Dascalescu Avatar answered Oct 03 '22 17:10

Dan Dascalescu


You host one website per github person or organization on the master branch. This is used for a personal website or organization website.

Such a personal or organization site is hosted on username.github.io in a dedicated repo in the master branch.

My personal blog for example is on takacsmark.github.io, it is hosted in a repo called https://github.com/takacsmark/takacsmark.github.io, the code is in the master branch of the repo and takacsmark.com is pointed to this site via the CNAME file in the repo.

In case you want to create a dedicated site for a project on github, you can create a project level github page. This means that it is not a separate repo, like the personal website example above. Instead, it should be under the gh-pages branch of the project repo.

Check out the bootstrap repo for a project gh-pages example.

like image 28
takacsmark Avatar answered Oct 03 '22 17:10

takacsmark


There can be two types of pages on GitHub. The first type has the files in the master branch and the repo has to be named the same way as the <username|organization>.github.{io|com}. There can be only one repository of this type.

The url of the pages is: http://<username|organization>.github.io or .com

The second type of pages doesn't put any restriction to the repository name, but the pages need to be in the gh-pages branch.

The url of the pages is: http://<username|organization>.github.io/<repo_name> or .com

More details here.

like image 42
Jiri Kremser Avatar answered Oct 03 '22 16:10

Jiri Kremser