Using select inputs to edit your data

Keep data linked and consistent by providing a fixed or dynamic set of options for select or multiselect inputs.

Color select input
SSG select input
SSG multiselect input
Color multiselect input

Inputs are selects or multiselects if their keys match a naming scheme linking to a data set source:

  • Multiselect when the input key matches or ends with with the data set key (e.g. colors or my_colors for data set colors)
  • Select when the input key matches or ends with with the singular form of the data set key (e.g. color or my_color for data set colors)

Input keys can be separated in a number of ways to match data set keys (e.g. my_color, my-color, myColor). The input key is flexible, but the data set portion must match entirely (e.g. my_staff_member matches staff_members, but does not match staff-members).

Fixed data sets

Fixed data sets are defined in your _select_data configuration. It’s useful for providing options that do not change as content is added or removed.

Configuration
color: Red
colors:
  - Red
ssg: jekyll
ssgs:
 - hugo
 - 11ty
_select_data:
  colors:
    - Red
    - Blue
  ssgs:
    jekyll: Jekyll
    hugo: Hugo
    11ty: Eleventy

Collection items

Collection items as a data set allow team members to link pages or data together by selecting from a list of existing items. This is useful when you need the available options to update each build.

By default, when you save a value populated from a collection, CloudCannon saves the path without the extension inside the collection folder (e.g. choosing /staff_members/jane.md in a staff_member input saves the value jane). You can use this value to map to the linked collection item in your templates.

Data files

Data files as a data set allow team members to link data together by selecting from a list of existing entries. Similar to collection items, this is useful when you need the available options to update each build.

Processed data sets must be arrays of strings, or single-level objects with strings as values. The value saved is either the string for array sources, or the key for object sources.

Data files match the naming scheme with the keys defined when they are included. By default, data files are not included in the generated output. Include specific data or all data with the instructions below:

To include all data, add the following to your _config.yml:

_config.yml
cloudcannon:
  data: true

Include only select data with specific keys:

_config.yml
cloudcannon:
  data:
    authors: true
    offices: true

Although not necessary, if you would like to generate the information file locally, add the following to your Gemfile:

Gemfile
gem 'cloudcannon-jekyll', :group => :jekyll_plugins
Important

Building with safe: true disables all plugins, including cloudcannon-jekyll. This is not recommended as it degrades the editing experience.

Was this article helpful? or Suggest an improvement >