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

Include a rendered page via pages.find

Started by Muut Archive 10 years ago · 5 replies · 427 views
10 years ago

Hi,

in a twig template i want to include a special page:

{{ pages.find('/sidebar').content }}

But "content" only returns the raw content of that md file. How can I get the rendered content with it's related twig template?

Using the above method grav doesn't even complain when there is no sidebar.html.twig present.

10 years ago

One option is you can include a twig template for that sidebar and pass in the content to it.

TWIG

{% include 'partials/sidebar.html.twig' with { content: pages.find('/sidebar').content() } %}
---
10 years ago

Hello rhukster,
i'm trying to use your way of implementing the content. But he just renders the content. Grav is not considering the media I added to the page.

Regards,

Michael

10 years ago

Media must be explicitly included in the page markdown. Are you doing so?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1359 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2956 9 years ago
Archive · by Muut Archive, 9 years ago
3 1121 9 years ago