Define your data

Last modified: March 27th, 2024

Working with a specific static site generator?
Customize CloudCannon's documentation to suit your SSG.

Great! We'll show you documentation relevant to .
You can change this any time using the dropdown in the navigation bar.

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.cjs
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.cjs
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.cjs
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.cjs
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.cjs
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.cjs
copied
module.exports = {
  data_config: {
    authors: {
      path: "data/authors.csv"
    },
    offices: {
      path: "data/offices",
      parser: "json"
    }
  }
};

Related Articles

Open in a new tab