Generate first class citizen pages from your data

roq-2.1 (4 Parts Series)

You have all that nicely structured content in yaml ou json, and all you would like is to generate static pages out of it. May that be events, catalog or any type of roq collection really.

However, if it was already possible to declare data using Roq via roq-data, for which it is even possible to have strong typing, it was not possible to extract pages directly from them. One could create pages by hand that used the data, or, as Stéphane Philippart did, generate pages programmatically from these…​

The first solution is useful if you only want a single page containing all the content. This is the case, for example, in this blog for the list of events that I gave. However, it is not possible to send a specific link to a particular talk.

Since Roq version 2.1, it is possible to automatically generate a page for each collection item simply by declaring it.

In the configuration file we just need to add:

application.properties
site.collections.events.layout=event (1)
site.collections.events.from-data.id-key=id (2)
1 Every collection item will be rendered using the events layout, which source can be found under <root_dir>\templates\layouts\events.html.
2 The property name to be used as identifiant

In this case one item of this collection would be found under the https://iamroq.dev/events/<slugified form of the title>.

And that’s all. There is NOTHING else to do. Ok, maybe the layout is still work to do. Ok. A minor peculiarity, for the moment item will be made available for the templating through the page data, even you have specified @DataMapping.

To access it in your Qute template you will have to use {page.data.title} (or if you use the alternative syntax {=page.data.title}).

The feature is beeing particularly usefull in this AI era where LLM are so keen to generate structured output.

We do not particularly like generated post, but it can be very usefull for summaries, check https://devoured.fyi/ that make good use of this feature !!!

Full documentation is already available.

Illustration by Lucas Santos