Defining Front Matter Variables with Data from a _data File

I have a _data file called nav.yml that contains all pages and all variables necessary. I also have each individual page in their respective .md files. In such a case, can I define front matter variable for my pages and posts from a _data file without copying and pasting everything? If not, is there a way to import front matter from each page and record them in a _data file?

EDIT: I use submenus in my navigation menu and some pages are not meant to be shown, which is why I would prefer to use _data files to organise and keep track of all relevant pages.

Only way I’m aware of setting default front matter is in your _config.yml using the defaults key

1 Like

Neither way is possible with jekyll. However you may generate it on a fly using site variables like so:

{% assign feeds = site.feeds | sort: ‘weight’ %}
{% for feed in feeds %}

(do collection…)

{% endfor %}

Take a look in this sample.