Page in snippet
warning A warning says what Statac did instead, and the build goes on.
A snippet is handed a page, and shows a field of page too. In a snippet,
page is the page being built, so on a page listing posts, page.title
is the list’s title every time, not the title of the post the call handed
it.
What you’ll see
warning Page in snippet: `card` shows `page.title`, the page being built
Did you mean `post.title`?
More: https://statac.dev/e/page-in-snippet/
In the terminal the message also names the file and line where there is one, and marks the exact text.
Why Statac warns
Sometimes a snippet means the page being built, such as marking the post that is being read. Statac can’t tell which you meant, so it builds the page as written and says so.
How to fix it
Read the field from the name the call hands the page by, as Statac offers.
If the page being built is what you meant, quieten this warning with
quiet: [page-in-snippet] in statac.yaml.
Example
In snippets/card.html, called as {{ card(post) }}:
<h2>{{ page.title }}</h2>
Show the post’s own title:
<h2>{{ post.title }}</h2>
Its name
| Name | page-in-snippet |
|---|---|
| In the terminal | statac explain page-in-snippet |
| To stop showing it | quiet: [page-in-snippet] in statac.yaml, once you have understood it. Statac still counts it. |
Something unclear or wrong? Open an issue on GitHub.