Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Custom frontmatter not working

Started by Muut Archive 9 years ago · 2 replies · 729 views
9 years ago

Hey there,

I just started playing with grav and ran into the following issue:

I have a file containing the following: (ignore the formatting, I had to push spaces before the lines because of the way code is declared on the forum :( )
--- yaml

YAML
   title: Anticipation
   img: anticipation.jpg
TWIG

and the following loop:
--- twig
<h1>Pictures</h1>
{% for p in page.collection('pictures') %}
    <article class="picture">
        <h2>{{ p.title }}</h2>
        {{ p.img }}
        <img src="/pictures/{{ p.title }}?resize={{site.thumbsize}}x{{site.thumbsize}}">
    </article>
{% endfor %}

But the output is:

--- html
<h1>Pictures</h1>
<article class="picture">
<h2></h2>

TXT
    <img src="/pictures/?resize=300x300">
</article>
TXT


I was under the impression that I don't need to specify custom front matter, am I wrong? How can I make this work?
9 years ago

img: anticipation.jpg is a Custom Page Header. Unfortunately you can not use Custom Page Headers in (exactly) the same way as Standard Page Headers like title.
For Standard Page Headers in Twig you can do: page.title while Custom Page Headers require: page.headers.img.

9 years ago

Thanks, that cleared things up for me, it is working with {{ p.header.img }}. :)

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1323 9 years ago
Archive · by Muut Archive, 9 years ago
2 920 9 years ago
Archive · by Muut Archive, 9 years ago
2 4048 9 years ago
Archive · by Muut Archive, 9 years ago
1 2924 9 years ago
Archive · by Muut Archive, 9 years ago
3 1106 9 years ago