Define your data

Last modified: October 18th, 2024

As of October 2024, this documentation is only applicable to Sites using Unified Configuration. For Sites that have not migrated to Unified Configuration, please read the documentation on our non-unified documentation website.

You can use data files and folders to populate your Select and Multiselect inputs. Using a data file or folder to populate your value options is useful when you want your team members to be able to edit the available options.

Data files/folders (i.e., data_config) are different to fixed data sets (i.e., _select_data).

For more information about fixed data sets, please read our documentation on Select and Multiselect inputs.

You can define your data files and folder in the CloudCannon configuration file under the data_config key.

To define a data file or folder:

  1. Navigate to your CloudCannon configuration file.
  2. Identify the data_config key at the root level of your configuration file, or add it if the key is not present.
  3. Enter a key name for your data nested within the data_config key.
  4. Add the path key within your data key and define the filepath to your data file or folder.
  5. Save your changes.

Your data file or folder is now available for Select and Multiselect inputs configured with this data key.

cloudcannon.config.yaml
copied
data_config:
  authors:
    path: data/authors.csv
  offices:
    path: data/offices

Configure all data files or folders under the data_config key in your CloudCannon configuration file.

Select and Multiselect inputs which use the authors key are populated by the contents of the authors.csv file.

Select and Multiselect inputs which use the offices key are populated by the contents of each file in the offices folder.

cloudcannon.config.json
copied
{
  "data_config": {
    "authors": {
      "path": "data/authors.csv"
    },
    "offices": {
      "path": "data/offices"
    }
  }
}

Configure all data files or folders under the data_config key in your CloudCannon configuration file.

Select and Multiselect inputs which use the authors key are populated by the contents of the authors.csv file.

Select and Multiselect inputs which use the offices key are populated by the contents of each file in the offices folder.

Options#

Your data configuration has the following options available:

data_config — Object#

This key defines which file or folder data in your Site is available to populate Select and Multiselect inputs.

This key has no default.

data_config.[*].path — String#

This key defines the file or folder path for the data key in which it is nested.

The value for this key is relative to your Site source. Each Collection must have a unique path.

This key has no default.

Show exampleHide example
cloudcannon.config.yaml
copied
data_config:
  products:
    path: data/products
cloudcannon.config.json
copied
{
  "data_config": {
    "products": {
      "path": "data/products"
    }
  }
}

Open in a new tab