-
-
Notifications
You must be signed in to change notification settings - Fork 1
Data Directory
The _data
directory in a Jekyll website is used to store data files which can be accessed throughout the site. These files are typically in YAML, JSON, or CSV format and contain structured data that can be used to generate content dynamically.
-
YAML Files:
.yml
or.yaml
files are used for configuration data or structured content. These files are easy to read and write and are ideal for storing things like site settings, lists, or any data that doesn't change frequently. -
JSON Files:
.json
files can be used for more complex data structures. JSON is a good choice when integrating with JavaScript or external APIs. -
CSV Files:
.csv
files are useful for tabular data. They are often used for simple lists or tables, and can be easily edited in spreadsheet software.
- Data stored in the
_data
directory can be accessed using thesite.data
namespace in your templates. For example, if you have a file namedmembers.yml
, it can be accessed usingsite.data.members
.
- Organization: Keep the data files organized and named clearly. This makes it easier to locate and edit the correct file.
- Data Separation: Use different files for logically separate data sets. For instance, keep team member data separate from product data.
- Version Control: Regularly commit changes to your data files in version control to track changes over time.