Defining your data

Last modified: June 1st, 2023

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:

specific doc

To include all data sets, add the following to your global configuration file:

cloudcannon.config.yaml
copied
data_config: true
cloudcannon.config.json
copied
{
  "data_config": true
}
cloudcannon.config.js
copied
module.exports = {
  data_config: true
};

Include only select data sets with specific keys:

cloudcannon.config.yaml
copied
data_config:
  authors: true
  offices: true
cloudcannon.config.json
copied
{
  "data_config": {
    "authors": true,
    "offices": true
  }
}
cloudcannon.config.js
copied
module.exports = {
  data_config: {
    authors: true,
    offices: true
  }
};

specific doc

To include all data sets, add the following to your global configuration file:

cloudcannon.config.yaml
copied
data_config: true
cloudcannon.config.json
copied
{
  "data_config": true
}
cloudcannon.config.js
copied
module.exports = {
  data_config: true
};

Include only select data sets with specific keys:

cloudcannon.config.yaml
copied
data_config:
  authors: true
  offices: true
cloudcannon.config.json
copied
{
  "data_config": {
    "authors": true,
    "offices": true
  }
}
cloudcannon.config.js
copied
module.exports = {
  data_config: {
    authors: true,
    offices: true
  }
};

specific doc

To include data sets with specific keys, add the following to your global configuration file:

cloudcannon.config.yaml
copied
data_config:
  authors: true
  offices: true
cloudcannon.config.json
copied
{
  "data_config": {
    "authors": true,
    "offices": true
  }
}
cloudcannon.config.js
copied
module.exports = {
  data_config: {
    authors: true,
    offices: true
  }
};

specific doc

To include data sets with specific keys, reader parses files and folders listed in data_config. In the following example global configuration there are two data sets:

  1. authors which is read from the contents of a single file
  2. offices which is read from the contents of each file in a directory
cloudcannon.config.yaml
copied
data_config:
  authors:
    path: data/authors.csv
  offices:
    path: data/offices
    parser: json
cloudcannon.config.json
copied
{
  "data_config": {
    "authors": {
      "path": "data/authors.csv"
    },
    "offices": {
      "path": "data/offices",
      "parser": "json"
    }
  }
}
cloudcannon.config.js
copied
module.exports = {
  data_config: {
    authors: {
      path: "data/authors.csv"
    },
    offices: {
      path: "data/offices",
      parser: "json"
    }
  }
};

Related Articles

Open in a new tab