Overview
The JekyllDataGem is a plugin that allows users to read data files within Jekyll theme-gems and incorporate the extracted data into the site’s internal data hash. This plugin provides a solution to the challenge of using configuration settings and data files within theme-gems, allowing them to be used in templates and work out-of-the-box with minimal user intervention.
Features
- Reads data files within Jekyll theme-gems and adds the resulting hash to the site’s internal data hash.
- Evaluates the _config.yml file within the theme-gem and incorporates the extracted hash data into the site’s existing config hash.
- Supports reading config files (currently only _config.yml) within the theme-gem and uses the data to modify the site’s config hash.
- Allows Jekyll themes to continue using configuration settings within their templates using the default site namespace (e.g. {{/* site.myvariable */}}).
Installation
To install the JekyllDataGem plugin, add it to your site’s Gemfile and config file, similar to other Jekyll plugin gems. Make sure the plugin is included in the :jekyll_plugins group in the Gemfile to avoid overriding data from the theme-gem. Here are the steps:
- Add the plugin to your Gemfile:
group :jekyll_plugins do
gem "jekyll-data"
end
- Include the plugin in your site’s config file:
plugins:
- jekyll-data
- Run the command to install the plugin:
bundle install
Note: If the plugin is marked as a runtime_dependency by the theme-gem’s author, it will be installed automatically when installing the theme-gem. However, it is recommended to add the plugin to the :jekyll_plugins group in the Gemfile to avoid overriding theme-gem data.
Summary
The JekyllDataGem plugin enables users to read and incorporate data files and configuration settings within Jekyll theme-gems. By adding the plugin to the Gemfile and config file, the plugin allows data files within the _data directory and the _config.yml file within the theme-gem to contribute to the site’s internal data hash and configuration hash, respectively. This plugin solves the challenge of using theme-gem data and configuration settings in Jekyll themes, allowing them to work seamlessly with minimal user intervention.