Github pages: Why do I need a gh-pages - jekyll

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

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.

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.

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.

Related

How can I create my own subdomain of my github.io page?

Not sure if this belongs here, but:
I have a github pages site, norway-yv.github.io. I want to create e.g. the subdomain of that subdomain short.norway-yv.github.io for URL-shortening (like, creating short.norway-yv.github.io/trains for my train-information repository project). How can I create the short.norway-yv.github.io subdomain using github pages?
You can’t.
Github offer you username.github.io for your main site and username.github.io/project-name for projects.

Editing index.html hosted on github pages

I have to make a very simple modification to a website which is being hosted on github pages (I just want to change the title in the index.html).
For simplicity I'd like to just modify and commit the change directly in the github code editor.
If I go to the github repo > Settings > Pages, I see that the under source it says "Your GitHub Pages site is currently being built from the gh-pages branch."
I have to switch from my master branch to the gh-pages branch to make the modifications and commit.
However I am not seeing any changes to the page, even after clearing the cache.
Am I misunderstanding how the github pages hosting works?
When you go to settings > Pages, you will see a dropdown menu for choosing which branch you want to post you website on. Just choose master .
After that you can easily edit whatever you want from github editor and then you have to commit the changes.
And after that you have to be a little patient till github servers save the changes and publish them for you.

Assistance needed with publishing a front-end html website with Github pages

So, uh, I'm really new to Github and would like to publish my Custom Seller Website (4 pages with interconnectivity, and an img folder with the pictures I use) via Github Pages. I have all 4 pages and the img folder in my repository, I deleted the description.md file (cause that was showing in the published page url) but it still shows the description when I go to the domain (username.github.io/...).. Any help is welcome! :)
Follow these steps to host your website
First create a new repository in github
Then push your code after your relevant commit to the github using git push -u origin master
Then go to settings in the repository
Go to the github pages section
Choose master from the dropdown under the source and click save
After refreshing the page you will see your website url under the github pages section

GitHub Organization Pages without named repository

Is it possible to create a website for a GitHub Organization (using GitHub Pages) without creating a repository with the same name?
As an example, for the organization CompPyrol, I created a repository that has the same name as the organization as comppyrol.github.io. The html and css files for the website are located in this repository. So the website for the organization is located at http://comppyrol.github.io. This works but I was hoping to use GitHub pages for an organization without having to create a repository just for the website. I know you can create an orphaned branch gh-pages for the web files but that seems to be for an individual repository or project, not for an entire organization page.
This is not possible. GitHub's documentation is quite clear:
User & Organization Pages
User & Organization Pages live in a special repository dedicated to GitHub Pages files. You will need to name this repository with the
account name, e.g.
atmos/atmos.github.io
You must use the username/username.github.io naming scheme.
Content from the master branch will be used to build and publish your GitHub Pages site.
Update:
GitHub Pages used to be served as subdomains of github.com, but switched to github.io in April, 2013. Some repositories are still set up using the old naming, but are now hosted on the new domain:
Changes to GitHub repositories:
User Pages repositories may now be named using the new username/username.github.io convention or the older username/username.github.com convention.
Existing User Pages repositories named like username/username.github.com do not need to be renamed and will continue to be published indefinitely.
If both a username.github.io and a username.github.com repository exists, the username.github.io version wins.

Can I create more than one repository for github pages?

I created a repository for hosting a blog on github.Is there any way that I can create more to host multiple blogs?Am I limited to just one repository for hosting(since username.github.com can only be used once?)
You can have one site published to https://<username>.github.io by publishing to the master branch of a repository named “username.github.io” (substituting your actual username).
You can also have an additional site per GitHub project published to https://<username>.github.io/<project>. Project settings let you choose which branch and directory to publish.
A better description is available in the GitHub Pages documentation, including options for using custom domain names.
(since April 2013, all username.github.com are now username.github.io)
No you are not limited, it is possible to have multiple GitHub Pages sites within one account. Create another GitHub repository and push your site files to the gh-pages branch. This would result in the site being hosted at tshepang.github.io/repo-name
Now, push another file "CNAME" to the same repository and branch and fill it with movies.tshepang.net. Log in to your DNS host and add the CNAME to point to "tshepang.github.io" (just like the original site).
This would allow you to have seemingly two different sites on different domains. This would not work for having two or more sub-domains within github.io itself.
There is a possibility to host multiple pages within the same repository having sub-pages if you are fine with code duplication.
The latest version of my website is hosted on http://username.github.io/REPONAME
This is a screenshot of the structure of my root repository where I host the latest version of my website:
Inside folder "2.4.0" I can host a previous version of the same page ,which is then reachable at: http://username.github.io/REPONAME/2.4.0
This is the structure of the folder 2.4.0:
Using this methodology of sub-pages within a main page, you can host multiple sub-pages within one main page.
You can only create one user or organization site for each GitHub account. Project sites, whether owned by an organization or a user account, are unlimited.
GitHub Pages sites
There are three types of GitHub Pages sites: project, user, and organization. Project sites are connected to a specific project hosted on GitHub, such as a JavaScript library or a recipe collection. User and organization sites are connected to a specific GitHub account.
To publish a user site, you must create a repository owned by your user account that's named <user>.github.io. To publish an organization site, you must create a repository owned by an organization that's named <organization>.github.io. Unless you're using a custom domain, user and organization sites are available at http(s)://<username>.github.io or http(s)://<organization>.github.io.
The source files for a project site are stored in the same repository as their project. Unless you're using a custom domain, project sites are available at http(s)://<user>.github.io/<repository> or http(s)://<organization>.github.io/<repository>.
The publishing source for your GitHub Pages site is the branch and folder where the source files for your site are stored. If the default publishing source exists in your repository, GitHub Pages will automatically publish a site from that source. The default publishing source for user and organization sites is the root of the default branch for the repository. The default publishing source for project sites is the root of the gh-pages branch.
I found a workaround if you don't want to make separate repositories for your different sites but just want to host them. In your io repo, create an index.html file on your master branch that acts as a table of contents linking to your other sites(subDirectories) index.html files. The username.github.io master branch seems to be the landing page that enables the hosting, so if it doesn't see an index file linking out to your separate projects, it won't register your subdirectories. After this all you need is the URL to whatever project you want to view. The io basically behaves like a giant single website with all your separate projects on it. Of course, if you would rather have separate repositories, gh-pages is the way to go.
Today I created another site and rather than creating branch gh-pages I have configured the master branch in a repository setting --> GitHub pages section select Source as master (or any other branch you want). You will get site link in the same section, in my screen shot I have removed site link.
This works, but ssl is still something I need to figure.
In my case GoDaddy is where my domains rest (url1.xyz), with nameservers pointing to Cloudflare. Then in Cloudflare the A records points to Github Pages. This is website 1 live, running fine. For website 2 I create a subdirectly in my gh-pages repo with website 2 files e.g. url1.xyz/static/website2/ - Then I create a subdomain in Cloudflare (subdomain.url1.xyz). Then create a page rule (url forward) from the subdomain to the subdirectory containing the 2nd website e.g. subdomain.url1.xyz >> mask forward >> url1.xyz/static/website2/ .. Then in GoDaddy I can configure url2.co.uk to mask forward to subdomain.url1.xyz , which presents website 2 e.g. url1.xyz/static/website2/
Just to add to the above. With one github user account(https://< username >.github.io) we can still have multiple static content websites hosted with different custom domains (Eg: domain1.com, domain2.com, domain3.com)We can just create a new repository for each domain and point the A record to github pages IP and CNAME record to < username >.github.io
You can create multiple blogs in your github account.
One repository can be created under your username. Push your code to branch gh-pages and you can see the site on <username>.github.io
Another one can be created under your organisation. For this you will have to create your organization first. Create a new repository under this organisation and push your code to gh-pages. You can see your site on <organization-name>.github.io
You can also create for each of your project and the site will be available on <username>.github.io/<repository>
Please refer this for more information on github pages.