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

Target headings and body copy in html.twig template?

Started by Muut Archive 10 years ago · 2 replies · 340 views
10 years ago

Can you use {{ }} expression to target <h1>Heading</h1>or <p>Body copy</p> in a markdown file?

Like the {{ content }} element will display the markdown of the page.

But can specify it, {{ content.h1 }} (I know it wont work, just illustrate)? So you can put <h1>Heading</h1> and <p>Body copy</p> in their div for easy positioning and styling?

10 years ago

I think your approach is quite difficult to realize. As long as there is only one heading this seems easy: writing a plugin and parse the contents which will be made available as a Twig variable. But how to deal with multiple headings? You may use some code I wrote for Toc plugin.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1370 9 years ago
Archive · by Muut Archive, 9 years ago
2 943 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1127 9 years ago