Manage non-existing file when running load_data

Is there a way to manage the case of a non-existing file while running load_data?

{% if exists(path="data/data.toml" %}
{% set data = load_data(path="data/data.toml") %}
{% else %}
{% set data = load_data(path="data/default.toml") %}
{% end %}

The use case is that I want to load a data file for each author in my authors taxonomy but I do not want the compilation to stop if an author does not have an associated data file.

Not currently.

1 Like

Ok thanks.

If someone asks himself the same function, the way I did this is to create an empty file (touch data.toml) and to test the presence of one of it’s elements:

{% set data = load_data(path="data/data.toml") %}
{% if not data.something %}
{% set data = load_data(path="data/default.toml") %}
{% end %}