Need Help with Image Issues on GitHub Pages for My Project

0
9
Asked By PixelPioneer92 On

I'm working on a rock-paper-scissors project, and while everything runs smoothly on my local machine, I'm facing issues with the images when I deploy it to GitHub Pages. If anyone has encountered this before or knows how to fix it, I'd really appreciate your help. Alternatively, if you're willing, you could clone my repository and help me troubleshoot the image problem. Thanks in advance!

3 Answers

Answered By CleverCoder88 On

It sounds like the issue might be with the image paths. Could you clarify what you mean by 'it doesn't work'? Are the images not showing up at all, or is there a specific error? Also, make sure you're using relative paths for your images since absolute paths may not work correctly on GitHub Pages.

Answered By CodeWizard77 On

You can use Vite’s URL() pattern for your assets to ensure they load correctly in your deployed app. Here's an example:

```javascript
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,
};
```
That might solve your problem.

Answered By DevGurl74 On

I agree with the previous reply. The problem often lies in incorrect file paths. You can try checking whether your image paths are relative to your project structure. This is a common issue when moving to deployment.

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.