Why Aren’t My Images Showing Up on GitHub Pages for My Project?

0
4
Asked By CuriousCoder92 On

I'm having a bit of a headache with my rock-paper-scissors project. It works perfectly on my local machine, but when I deploy it on GitHub Pages, the images just won't show up. Has anyone else run into this issue before? If so, any chance you could share how you fixed it? Or, if you're up for it, feel free to copy my repository and take a look yourself. Thanks a bunch!

3 Answers

Answered By CodeSleuth On

Sounds to me like your image paths are incorrect. Always good to verify them! Maybe try clearing your cache and refreshing the page too, just to be sure the latest version is loading.

Answered By TechWhiz123 On

I think the issue might be with your image paths. Are you sure you're using relative paths? If your images aren't displaying on GitHub Pages, they might not be pointing to the right place. Double-check that!

ImagePathNerd -

Yeah, it definitely sounds like that. Make sure to check how your paths are set up.

WebDevPro -

Exactly, relative paths are usually the way to go for deployed projects.

Answered By DevGuru99 On

Have you tried using Vite’s new URL() method for your assets? It looks something like this:

```
const icons = {
rock: new URL('../img/stone.png', import.meta.url).href,
paper: new URL('../img/paper.png', import.meta.url).href,
scissors: new URL('../img/scissors.png', import.meta.url).href,
};
```
This might help you get the correct paths for your images when they're deployed!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.