Easily Use Design Tokens In Eleventy

1 · Heydon Pickering · May 16, 2020, midnight
This is going to be a very short article, because it turns out working with design tokens in Eleventy is a partition of urine (very easy). Eleventy’s root /_data folder lets you define some global (you guessed it) data that can be accessed in templates anywhere in the site/project. So, if I create a tokens.json file in my _data folder with a colorLight property, I can interpolate it as {{ tokens.colorLight }} in any of my nunjucks templates. Here’s /_data/tokens.json: { "colorLight": "#eee", ...