Search code examples
htmlcssgithub-pages

HTML pages inside the pages folder not loading style.css main directory


Hopefully I worded the title correctly and in a way that explains my issue. Basically, there is a style.css in the main directory and I have multiple html files that reference it. I decided to put all the html files (except index.html) inside a pages folder to keep it organized. It works fine when I view it as a live server in VS code but the issue happens when I try to view it as a github page. Here is the link to the repository: https://github.com/dacevedo11/TheWitchIsDead/tree/main

This is what the link to style.css looks like inside index.html <link rel="stylesheet" href="style.css"> This is what it looks like on the other pages inside the folder. <link rel="stylesheet" href="/style.css">

I tried changing it to match index.html. As expected, that didn't work. I also found some people suggesting ../ for similar problems but that didn't work either. I checked for issues for capitalization or maybe misspelling but didn't notice anthing. But then again it wouldn't work in vs code if that was the case. I'm specifically having this issue on the github page


Solution

  • This is what the stylesheet reference needs to look like in all the html files in the pages folder:

    <link rel="stylesheet" href="../style.css">