GitHub Pages Not Rendering HTML or MD Files on Newly Created Repository - github

I've been working with GitHub Pages but for the life of me my pages will not render.
I've named the repository with the account username along with the postfix of github.io, yet when I go to the designated URL to view the GitLab Pages I get a 404 error.
It's a new account, a new and correctly named repo with Jekyll and HTML pages in the root of the project. Yet 404 errors abound. Any thoughts?

What branch are you on?
GitHub Pages only currently renders files on the master branch. However, new repos do not create a master branch. They create a branch called main to avoid the racist overtones of the term master.
So you will need to create a new branch called master and add Jekyll and HTML files there. Commit and push to GitHub and your GitHub pages will work.
Basically, make sure your files are in the master branch. Soon GitHub Pages will likely use the main branch by default but not yet.

Related

Is it possible to only have one gh-pages repo?

Last year I have been working on a project, that required gh-pages. Everything was totally fine and hosted on Github Pages. Today I started to work on another project, that will also require gh-pages. However when I started pushing local repo to github, I realized something. Somehow this newly created react app already had a remote origin with a link to that first last-year repo. How is it possible? Will my first repo stop working if I use gh-pages with this new project?
gh-pages pages is (or, rather, should be!) a branch not a repo. Your new new project should be in a new repo. Two repos can, of course, both have branches with the same name.
It sounds like you have set up the repos or the remotes for the repos incorrectly. Can you please edit your question to add the URLs of the two repos and the results of running git remote -v in the local checkouts of the two repos.

Publishing new GitHub page

I have a site published at username.github.io and want to publish a different one. How do I replace it with a project in a new repository? I switched my default file in the new one to gh-pages and that published it under username.github.io/Repository but now when I push changes they go to the master branch and don't change on the published site. Confused and just looking for easiest way to replace my old site with the new one, thanks.
A User page (<username>.github.io) differs from a Project page (http(s)://<username>.github.io/<projectname>): its pages can only be published from master.
For the former (User Page repo), all you have to do is:
checkout the master branch
delete your files and commit
add your new files (for the new site) and commit.
That will replace your existing User page web site.
I switched my default file in the new one to gh-pages and that published it under username.github.io/Repository
That is a project page, and putting those files on master won't make them published on a User Page repo.

Can I redirect one branch of a GitHub repository?

I know that GitHub has automatic redirects if you move/rename an entire repo. But I have the following scenario:
Project whizbang has several branches.
One of the branches needs to be moved into its own repository, so that whizbang/8.x branch becomes a new repository named whizbang8.
Old links pointing to project whizbang/8.x branch need to be
redirected to the new repository.
Is this possible?
Old links pointing to project whizbang/8.x branch need to be redirected to the new repository.
Not that I know of: a GitHub URL for a branch later exported in its own repo would still point to the old repo (branch), and not to the new repo.

github site from gh-pages branch

I have GitHub site like example.github.io and want to load this site from the gh-pages branch!
how can I do?
now I can't change branch because my repository name is example.github.io
When you create yourusername.github.io you have to commit directly to master. It's meant as a website (unlike a repo that has a website that hosts to yourusername.github.io/reponame/*.
Since you already have a branch with the website, just merge it into the master branch. This can be done from the command line, the Github website or Github Desktop.
The logic
Example: You have a repo (username.github.io). You also have two repos set up with Github pages: repo-1 and repo-2.
username.github.io is the root. You're free to do pretty much anything you want with it. Creating directories will be relative to the root of the domain. When you connect to the domain, it finds the files from the master branch. If you go into the repo settings for username.github.io, you'll see this:
You're locked to the master branch. You can still use other branches for adding features, but what the actual website consists of is what's on the master branch.
The difference between the username.github.io repo and repo-1 or repo-2 is that username.github.io allows editing access to the directory root (e.g. http(s)://username.github.io/index.html) where as repo-1 and its connected pages would be at http(s)://username.github.io/reponame/index. Since the website is most likely wanted to stay out of the source itself, you can use an alternate branch to host it.
If you go into settings for repo-1 or repo-2, you'll see this:
Here you can pick. If you have multiple branches, you can select a different one to host the pages. You can also select the option to use the /docs folder for the website.
TL:DR; When using username.github.io, the master branch is the one that actually hosts the website. Think of it as the production branch. The others can't be accessed from the website
From the OP's comment:
So I can't use the gh-pages branch for Github site! yes?
Update Sept. 2020: yes, you now can.
You can use any branch you want.
"Build and deploy GitHub Pages from any branch"
Repositories that use GitHub Pages can now build and deploy from any branch.
Publishing to the special gh-pages branch will still work the same as it always has, but you can now choose a different branch in your repository as the publishing source.
This functionality also removes the hardcoded dependency on user and organization pages having a master branch.

gh-pages across Github projects all link to domain

I'm using GitHub Pages and Jekyll on my repository and have linked the repository to my own URL.
So, rimager.github.io links to rimagerhard.com
When I create a new repo and push to the gh-pages branch, that repo becomes available under my URL as well. For instance, I pushed to my literary-quotes gh-pages branch and poof, it's all up under http://www.rimagerhard.com/literary-quotes/
Could someone explain to me why this is happening? I am feeling a bit obtuse today. Thanks :)
Once you set a custom domain on Github, it sets a permanent redirect from rimager.github.io to rimagerhard.com.
As rimager.github.io/literary-quotes is considered as part of the domain, the redirection applies.