josua oconner
josua oconner

Reputation: 1

Why the images not found after deploying react js to github pages?

After deploy my react project to github pages, i've got some error. all the images not displaying. i've been try some solution like change the path from '../' to './' nothing happen, then i change to '/', it also doesnt show the images. Then i try to moved all the images to public folder. still nothing happen

this is the solution that i've tried

<img src="src/assets/img/ramen.jpg" />
<img src="./src/assets/img/ramen.jpg" />
<img src="./public/assets/img/ramen.jpg" />
<img src="/public/assets/img/ramen.jpg" />
<img src="public/assets/img/ramen.jpg" />
<img src="assets/img/ramen.jpg" />

this is my repository https://github.com/callmecua1/Kitsune

Upvotes: 0

Views: 121

Answers (2)

Shaiming Pai
Shaiming Pai

Reputation: 1

First Method:

Move ur image directory in src/assets directory the indicate the URL.

Second method:

-Import images as a variable

Import myImg from 'Your-Image-URL'

-Then use this variable

<img src={myImg} ..>

Upvotes: -1

Sara tabaghchi
Sara tabaghchi

Reputation: 293

If files in this root

public/images/ Use this root

'/images/imagename.jpg'

But if folder inside src(/src/images) And keep your image in it Use this root

'./images/image-name.jpg'

Upvotes: 0

Related Questions