Data
Cook loads config/data.js at build time and makes its exported values available as template strings on every page. Combine this with front matter for page-level overrides.
Basic data file
Export a plain object with string values. Each key becomes a ${variableName} you can use in any HTML, JSON, or webmanifest file.
export default { siteTitle: 'Outdoor Gear Co.', siteDescription: 'Premium outdoor equipment since 2019', year: new Date().getFullYear().toString(), themeColor: '#1a5c2e',};
Use these values in templates with ${variableName} syntax:
<title>Cook SSG</title><meta name="description" content="A platform-native static site generator. ES6 template literals for templating, custom elements for components, file-based routing by default."><footer>© 2026 Cook SSG</footer>
Nested data
Use dot notation to organize related data. Access nested values with ${parent.child} in your templates.
export default { site: { title: 'Outdoor Gear Co.', url: '<a href="https://www.outdoorgear.co">https://www.outdoorgear.co</a>', description: 'Premium outdoor equipment', }, social: { twitter: '@outdoorgearco', github: 'outdoor-gear-co', },};
<title>${site.title}</title><a href="<a href="https://twitter.com/$%7Bsocial.twitter%7D%22>Twitter</a">https://twitter.com/${social.twitter}">Twitter</a</a>>
Async data loading
Export a function instead of an object to load data dynamically at build time. Cook will await the function if it returns a promise.
export default async function () { const response = await fetch('<a href="https://api.example.com/products">https://api.example.com/products</a>'); const products = await response.json();<p></p><p> return { siteTitle: 'My Store', products, buildDate: new Date().toISOString(), };}</p>
This is useful for pulling data from APIs, reading files, or running any Node.js code at build time.
Dynamic imports
For data that requires heavy dependencies, use dynamic import() inside the function:
export default async function () { const fs = await import('node:fs/promises'); const packageJson = JSON.parse( await fs.readFile('./package.json', 'utf-8') );<p></p><p> return { version: packageJson.version, siteTitle: packageJson.name, };}</p>
How data flows
- Cook loads
config/data.jsonce at the start of the build - If the export is a function, Cook calls it and awaits the result
- The resulting object is passed to every build plugin that needs data
- For template string resolution, front matter values are merged on top of global data, so page-level values override global ones
- Template strings (
${key}) are replaced with their matching data values
Arrays and collections
Data can include arrays, which are especially useful with data-repeat:
export default { siteTitle: 'My Blog', navLinks: [ { label: 'Home', url: '/' }, { label: 'Blog', url: '/blog/' }, { label: 'About', url: '/about/' }, ],};
See Template Strings for how these values get resolved and Data Repeat for iterating over arrays.