How to display text above blog pages with Grav

October 09, 2019

For this website I wanted to run multiple small blogs alonglines and have category pages for "Gestaltung" and "Education". I wanted some decorative, introductory text above the blog posts rendered through

    items: @self.children

I wanted something that now looks like this:


The way to display a blog in Grav is to use a unique power of grav. You create a page and define in its YAML section that this page should simply display links to all posts in folders that are children to this file's place.

    items: @self.children

Adding this (and a blog.html.twig in your theme's templates folder) just creates a blog functionality. But how to get some intro-text above? My first guess was that adding text in the content section (below YAML) would display. But of course it doesn't.

Using modules

I am now using the modules functionality of Grav. I render a page, it's upper module is a page and it's lower module is the page. This gives you the following structure for my Gestaltung-page:

folder structure

The carries this as its code:

title: Gestaltung
onpage_menu: true

    items: '@self.modular'
        by: default
        dir: desc

It simply displays all modular pages within that folder (being, _blog and _descr) in descending order. That gives me the description file on top. The file within _descr is super simple.

The tricky part war getting the list of posts from to work. I am using the cacti for its multilanguage support. That has the blog functionality working with a file that connects to a post-list.html.twig. Either works, in Grav its just words. They work the same. No matter how you name it, matters what carries the same name.