Search code examples
node.jsexpresspug

Cant display static image in jade


I can't display image, image is in the same folder.

  each user,i in users //users data loop
    h2=user.name
    .card
      img(src='img_rr_01.jpg', alt='Avatar', style='width:100%') // Image 
      |   
      .container
        h4
          b=user.email
        |  
          p=user.name 

Solution

  • Make sure you are specifying your public assets folder by mentioning something like this -

    app.use(express.static(path.join(__dirname, "/../public")));
    

    Then your static file's paths should normally be starting with / and then follow the path as it is in your public folder. e.g. if your image is in public/images folder, then update your src to be /images/img_rr_01.jpg.

    Please note that you need not mention public folder in your src.