Jekyll Image Variable

Hi everyone,

Now, I just tried to do this:

In the post:

---
title: THE_TITLE
img: http://i.imgur.com/kX22nWu.png
---

In the main layout:

However, it is not working. =(


Can someone help me?
Thanks a lot.

try {{page.img}}

it is a page variable. You probably also need {{page.title}} for the alt one too.

This can be confusing as frequently you will see a loop where they do for post in site.posts... post.title, post.date etc so it looks like post is the thing to use, but in a loop you can call that anything - I try to use item in my loops as it is more clear to me.

It’s probably an error in the front matter because the image URL is not in quotes. You can’t have a second colon ( : ) in the value without quotes. Try:

---
title: THE_TITLE
img: "http://i.imgur.com/kX22nWu.png"
---