Page Objects & YAML Front Matter

Hi,
My code for post-item.html.twig can be found here

So I am attempting to show the first image in the blog post on the screen above, hence, I have included {% set blog_image= page.media.images|first %}. However, I am unsure of how to call on this in the , and no image is showing up.

Moreover, it seems that there is something wrong with my YAML Front Matter as I specify the Page Author {{ page.header.author }}, however when it displays on the site (as shown in the image) it shows nothing, despite me adding an author in the post.md

Any help would be fantastic!

Due to image restrictions, here is the information I wish to change.

as you are in a for loop, you have to use the variable you defined, in this case post.

Example:

{% for post in page.children %}
{{post.title }}
{{ post.header.author }}
{{ post.media.images|first }} {# will display the img tag #}
<img src="{{ post.media.images|first.url}}"
{% endfor %}

Also you have some kind of weird syntax here:

<img src="$blog_image.url" alt=""/>

Where does this come from?

Hope it helps,

1 Like

Ahh Perfect! Thank you for that! You’ve fixed all my problems!
Cheers.