Skip to content

Data Directory

thomasthaddeus edited this page Dec 8, 2023 · 1 revision

Documentation for _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.

Directory Structure and Usage

  • 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.

Accessing Data

  • Data stored in the _data directory can be accessed using the site.data namespace in your templates. For example, if you have a file named members.yml, it can be accessed using site.data.members.

Best Practices

  • 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.
Clone this wiki locally