SED
SED

Reputation: 110

Image not displayed on page - (Express, Pugjs)

I am trying to display an image on my page using pug template, but the image is not displayed on the page.

I have the following setup/ files:

index.js

app.use('/images', express.static(path.resolve(__dirname, '../dist/assets')))

template.pug

img.logo(src='/images/logo.png')

The logo.png is located in the /dist/assets/ folder.

I don't get any errors but the image is not loaded/ displayed and when I open the image link from the developers tool in a new tab, the image is shown. Not sure if I am missing anything. Can anyone please explain why this is not working?

Upvotes: 0

Views: 883

Answers (1)

David R
David R

Reputation: 15639

You are using logo property to set the image path which is wrong.

It shoud be:

img.image(src='/images/logo.png')

Upvotes: 2

Related Questions