# Can I have post.image without accessing front matter

**URL:** <https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597>\
**Category:** Help\
**Created:** [March 18, 2018, 5:19am UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597 "2018-03-18T05:19:10Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [March 18, 2018, 5:19am UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597/1 "2018-03-18T05:19:10Z")

</div>

I need page.image called in post layout and post.image called in home layout. Can I set in markdown without acessing front matter?  
Something like `{% assign image = https://s18.postimg.org/6jl4ysnkp/India_Government_Jobs.png %}`

Thanks.

---

<div class="post-metadata">

**Author:** ![pabloduo](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@pabloduo](https://talk.jekyllrb.com/u/pabloduo)\
**Post date:** [March 18, 2018, 5:41pm UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597/2 "2018-03-18T17:41:55Z")

</div>

@justinechacko, take a look at these guidelines about includes in Jekyll official documentation: [https://jekyllrb.com/docs/includes/#passing-parameters-to-includes](https://jekyllrb.com/docs/includes/#passing-parameters-to-includes) - it could be what you’re looking for.

Given the little context about your use case - it is hard to come up with a recipe that fits. 😉

---

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [March 18, 2018, 6:02pm UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597/3 "2018-03-18T18:02:50Z")

</div>

Hmm. I will explain. Assume I am writing post but I don’t have access to front matter of post.(not post.html layout but posts in \_posts folder) . Then can I set post.image property (I don’t know what it is called, but I say property) in the body part?

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [March 18, 2018, 8:54pm UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597/4 "2018-03-18T20:54:20Z")

</div>

`post.image` isn’t a thing on its own - when you access front matter it would be `page.myvariable` - though sometimes in a for loop people call the iteration part `post` which could give you `post.image`. I assume that is what your layout is doing.

It sounds like you have a layout that is using image(s) specified in the front matter? and you want to be able to set that in the MD content of a post, not the posts front matter?

If that is the case I doubt you can do it.

I’m sure you could accomplish something similar via JS.

---

<div class="post-metadata">

**Author:** ![pabloduo](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@pabloduo](https://talk.jekyllrb.com/u/pabloduo)\
**Post date:** [March 19, 2018, 6:31am UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597/5 "2018-03-19T06:31:04Z")

</div>

@justinechacko, okie - another attempt. Would Front Matter defaults help in your case: [https://jekyllrb.com/docs/configuration/#front-matter-defaults](https://jekyllrb.com/docs/configuration/#front-matter-defaults)?

So, are you looking for a way to do something like `page.hero_image = /images/hero/xyz.png` inside `_posts/2018-03-18-spiderman.md` for all files (`*.md`) inside `_posts` folder?

If that not what you’re looking for - can you bring up the actual code & problem you’re having difficulties with?

---

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [March 19, 2018, 7:15am UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597/6 "2018-03-19T07:15:37Z")

</div>

> So, are you looking for a way to do something like page.hero\_image = /images/hero/xyz.png inside \_posts/2018-03-18-spiderman.md for all files (\*.md) inside \_posts folder?

Yes but images link will change in each posts

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [March 19, 2018, 2:30pm UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597/7 "2018-03-19T14:30:03Z")

</div>

If you can’t access the front matter have you tried using a [Liquid `{% assign %}`](https://help.shopify.com/themes/liquid/tags/variable-tags#assign)?

---

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [March 19, 2018, 2:58pm UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597/8 "2018-03-19T14:58:53Z")

</div>

I tried like this.

`{% assign image = https://s18.postimg.org/6jl4ysnkp/India_Government_Jobs.png %}` but not working

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [March 19, 2018, 8:22pm UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597/9 "2018-03-19T20:22:26Z")

</div>

I don’t think `image` will work because your layout is expecting `post.image`.

Have you tried `{% assign post.image = "https://whatever.com/image.png" %}` or `{% assign page.image = "https://whatever.com/image.png" %}`

---

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [March 20, 2018, 12:34pm UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597/10 "2018-03-20T12:34:59Z")

</div>

@mmistakes still not working

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [March 20, 2018, 12:46pm UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597/11 "2018-03-20T12:46:54Z")

</div>

Then it’s not possible. You’ll need to add it as front matter.

---

<div class="post-metadata">

**Author:** ![justinechacko](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/justinechacko/32/675_2.png) [@justinechacko](https://talk.jekyllrb.com/u/justinechacko)\
**Post date:** [March 22, 2018, 9:48am UTC](https://talk.jekyllrb.com/t/can-i-have-post-image-without-accessing-front-matter/1597/12 "2018-03-22T09:48:06Z")

</div>

Okey. Thanks for replying
