skip to Main Content

my image are in the public directory I still don’t know why isn’t displaying on both my local host and GitHub pages

I have tried checking the path and still getting the same issue, I even tried moving the images into my main folder directory but still it didn’t work.

2

Answers


  1. First of all if you use images inside components or pages, you should move them into src folder and for best practice, you should store them in assets folder inside src.
    but if you just only want to use them inside public folder, for instance in index.html file, you should write href(src) like %PUBLIC_URL%/your_img.png

    Login or Signup to reply.
  2. You have import the images into your component like this:

    import image from "./public/image.svg"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search