Reputation: 1
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
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
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