Can I have post.image without accessing front matter

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.

@justinechacko, take a look at these guidelines about includes in Jekyll official documentation: 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. :wink:

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?

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.

@justinechacko, okie - another attempt. Would Front Matter defaults help in your case: 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?

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

If you can’t access the front matter have you tried using a Liquid {% assign %}?

I tried like this.

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

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" %}

@mmistakes still not working

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

Okey. Thanks for replying