Access frontmatter data elsewhere #3209
-
Hello, I'm a bit stuck. I can access a custom frontmatter Here's the deal. I have a blog post. It has the following front-matter:
On the home page, I have a list of all my blogs with the
This works perfectly. But I also want to use the same cover image when the post is opened. So I try to include it in the
The |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Not sure if - {% set img = post.data.img %}
<img src="{{ img }}" class="w-screen object-cover" alt="" /> Although that wouldn't work if you use that layout but didn't happen to have |
Beta Was this translation helpful? Give feedback.
Not sure if
post
would be defined in your layout, outside the scope of the home page'sfor..in
loop.Wouldn't it just be
{{ img }}
in the layout and not try setting it:- {% set img = post.data.img %} <img src="{{ img }}" class="w-screen object-cover" alt="" />
Although that wouldn't work if you use that layout but didn't happen to have
img
frontmatter for that page.