Eleventy with environment variables

Some lush mountains at sunset

Environment variables are handy in Eleventy but did you know that you can use them inside your markdown files?

By using a JavaScript data file, we can expose process.env variables that might be in an .env file, your hosting provider’s dashboard, or even in your Docker setup.

This is one of two versions of this site. Head over to the other site to see the differences.

Here’s an example: The environment variable, HELLO is currently: “Hi there, I am set in an environment variable 👋”. This is called with {{ env.hello }}.

This is secret content that only shows if we’re in private mode.

This is called with {{ env.mode }}. This is great for doing special private builds of the site for people that pay for content, for example.

Enable fun mode.