-1

I have tried several methods to host my website on GitHub, but nothing worked. It seems like GitHub is not linking my css to the html, but its working absolutely fine on my local desktop.

Here is my repository : https://github.com/Anand-Anurag/Travelly.github.io

Here is my hosting link : https://anand-anurag.github.io/Travelly.github.io/

Please Help Me.

  • 1
    Change from `href="/css/style.css"` to `href="./css/style.css"` and will work. Also add that dot to all imgs. https://stackoverflow.com/questions/7591240/what-does-dot-slash-refer-to-in-terms-of-an-html-file-path-location – jonu29 Jan 04 '22 at 10:09
  • JUST A TIP: you don't need to write the name of the repo with `.githu.io` just the name is enough, Github pages do it automatically for you... so from *https://anand-anurag.github.io/Travelly.github.io/* will be *https://anand-anurag.github.io/Travelly/* – Laaouatni Anas Jan 04 '22 at 10:16
  • It Worked, Thanks Alot Sir, but what was the error I couldn't understand it, Please tell me if you can, but Thanks Alot again Sir... – Anurag Anand Jan 04 '22 at 10:17
  • Welcome to Stack Overflow _ To find out more about adding dots `./` to href paths visit this SO post >>> https://stackoverflow.com/questions/7591240/what-does-dot-slash-refer-to-in-terms-of-an-html-file-path-location – inputforcolor Jan 11 '22 at 14:32

1 Answers1

0

Your code is trying to find the CSS at https://anand-anurag.github.io/css/style.css but it actually is located at https://anand-anurag.github.io/Travelly.github.io/css/style.css so you'll need to adjust the path.

Right now you are using /css/style.css to refer to your stylesheet. This will look at the root of the current url. If you replace this with ./css/style.css it will be relative to the current path.

More details can be found in this stackoverflow answer.

Felix G
  • 380
  • 2
  • 13
  • 1
    And how OP should fix it? You are pointing the error but not giving a solution or explaining why this error is raising (I.e. absolute vs relative paths) – Lelio Faieta Jan 04 '22 at 10:18