Skip to content

Data Directory 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 Data Directory File

To create a data directory 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 data directory 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