Shared data

Reuse the same data in multiple pages

In the previous step we created two pages using the same layout, by defining the variable layout in the front matter. This can be fine for a few pages but what if you have tens, hundreds, or thousands of pages using the same layout? _data files to the rescue!

Create a _data file

In your project directory, create a _data.yml file with the following content:

layout: layout.vto

This is a special file containing data shared by all pages in the same directory or subdirectory. In this file we have defined the variable layout so all pages inherit this variable too. We not longer have to repeat it in the front matter of all pages, so we can remove it from there.

layout: layout.vto

Tip

_data files (and _data folders) are a very powerful feature of Lume. See the shared data documentation for more examples.