Skip to content

Directory Data File

Posted on: Feb 15, 2021 by Stephanie Eckles
🍿 1 min. read

Quickly assign settings to a collection instead of repeating the info in each content's front matter.

Create a Directory Data File

To create a directory data file, add a json file within your directory with the same name as the directory.

For example, within /posts/ create posts.json.

Assign Tags and Layout

Most often, I use directory data files to quickly create collections via tags and also to assign all the directory content to a layout.

"tags": "posts",
"layout": "post"

If needed, you can still override these values within the front matter of individual files.

Another very handy feature is the ability to change the permalink structure for all content within directory.

Here's one example of assigning content to live off the root instead of retaining the directory as a prefix:

"permalink": "/{{ {{ page.fileSlug }} }}"

Review more permalink structure tips

View more quick tips