Defining data allows you to populate select and multiselect inputs. Each data set corresponds to a file or folder in your site files.
By default, CloudCannon does not read the contents of data files during your build. If required, include data with the instructions for your SSG:
Jekyll content
To include all data sets, add the following to your global configuration file:
data_config: true
{
"data_config": true
}
module.exports = {
data_config: true
};
Include only select data sets with specific keys:
data_config:
authors: true
offices: true
{
"data_config": {
"authors": true,
"offices": true
}
}
module.exports = {
data_config: {
authors: true,
offices: true
}
};
Hugo content
To include all data sets, add the following to your global configuration file:
data_config: true
{
"data_config": true
}
module.exports = {
data_config: true
};
Include only select data sets with specific keys:
data_config:
authors: true
offices: true
{
"data_config": {
"authors": true,
"offices": true
}
}
module.exports = {
data_config: {
authors: true,
offices: true
}
};
Eleventy content
To include data sets with specific keys, add the following to your global configuration file:
data_config:
authors: true
offices: true
{
"data_config": {
"authors": true,
"offices": true
}
}
module.exports = {
data_config: {
authors: true,
offices: true
}
};
Other content
To include data sets with specific keys, reader parses files and folders listed in data_config
. Add the following to your global configuration file:
data_config:
authors:
# Reads the contents of this file
path: data/authors.csv
offices:
# Reads the contents of each file in this directory
path: data/offices
parser: json
{
"data_config": {
"authors": {
"path": "data/authors.csv"
},
"offices": {
"path": "data/offices",
"parser": "json"
}
}
}
Populates authors
with the contents of the data/authors.csv
file. Populates offices
with the contents of each file in the data/offices
directory parsed as JSON.
module.exports = {
data_config: {
authors: {
// Reads the contents of this file
path: 'data/authors.csv'
},
offices: {
// Reads the contents of each file in this directory
path: 'data/offices',
parser: 'json'
}
}
};