How do I add an image in a Meteor template file?

139 Views Asked by At

I am currently making a Meteor website with multiple pages and using IronRouter to have my /client/main.html display a page frame and import several HTML templates located in /imports/ui. I have an HTML <img> element located inside one of the templates-- /imports/ui/home.html.

Where do I need to put the image file and what do I need to put as the href= to find the image properly?

I have already tried both using a /public directory, and putting the image in the /imports/ui file and then trying to link to it with both the image name itself (as if the template were calling the image from its own folder) and using /../imports/ui/image.jpg as if main.html (the page with the frame and Ironrouter links) were calling the image file.

1

There are 1 best solutions below

0
Christian Fritz On
  1. Put your image file (e.g., image.png) in /public.
  2. Use <img src="/image.png"/> in your html (note: img tags use src not href attributes -- an easy mistake to make).

More details here.