Search code examples
htmlgithubgithub-pages

Issue with uploading website successfully to GitHub Pages


I'm having an issue with uploading my website to GitHub pages. I am a beginner and have just made my first website that uses several html files. I have created a repository for this website. The website contains index.html, and 2 other html files. When I first open the website through GitHub Pages it appears to be fine, however if I click on a link on the website which takes me to the main page (the main page being index.html) it opens up a completely different website from my other repository. I realised this is because it uses the same url (username.github.io/index.html) as my other repository. Since both of these are the same I guess it just opens up my other website because it was created earlier.

This is my first issue. I also have another issue. My other 2 html files have a unique html file name, but when I open the link for them I get a 404 error:

"The site configured at this address does not contain the requested file."

From what I understand, a GitHub Pages URL would look like this:

username.github.io/repository name/html file name.

My website looks fine when I open it with this URL:

username.github.io/repository name

However, when I click on any link on the website the URL loses it's repository name and changes into:

username.github.io/html file name which brings up a 404 error.

I don't understand why it does that.


Solution

  • The URLs in your links start with /, which points at the root of the domain.

    Don't do that.