Home > Net >  Background image from css is not visible on github, but visible in localhost
Background image from css is not visible on github, but visible in localhost

Time:04-26

I have made a project just for fun in which i had applied background images from css, they are very well working in localhost but when uploaded on github all the images are visible except the one on the background. The link for the github is below. https://github.com/AmanShahwaz/Driver-s-Community

Thanks in advance

CodePudding user response:

Here is your problem:

<img src="/D-Community/imgaes/1.jpg" alt="" srcset="">

Your repo name is "Driver-s-Community", which is also the base URL of your github pages site (https://amanshahwaz.github.io/Driver-s-Community/).

However, your code URLs link to https://amanshahwaz.github.io/D-Community/, which simply does not exist (it did not at the time of writing), and thus gives the broken links. This is probably due to you having a different name for your local folder from your repository name. To prevent such conflicts, you should keep both names consistent.

The solution is to either rename your local working directory to "Driver-s-Community" or your repo to "D-Community", and change your base URLs accordingly.

If you rename your local folder to Driver-s-Community, then your URLs should look something like this:

<img src="/Driver-s-Community/imgaes/1.jpg" alt="" srcset="">

Otherwise, no need to change your URLs.

Also, just as a side note, considering your project structure, you should probably use ./ instead of explicitly typing out your base URL. This helps to avoid such mishaps.

Hoped this helped and if it did, please mark as accepted answer. Thanks!

P.S. you have a typo in "imgaes", should be "images". :)

  • Related