jm13fire
jm13fire

Reputation: 195

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

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.

Upvotes: 0

Views: 150

Answers (1)

Christian Fritz
Christian Fritz

Reputation: 21374

  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.

Upvotes: 1

Related Questions