Environment Variables are useful for feeding the build process of your static site information from outside of your site’s code. This allows for information like API keys to be stored and provided securely, rather than in your site’s code as clear text.
Adding Environment Variables
Special Characters in Environment Variables
Environment variables are applied literally, with the exception of commas, parentheses, and double quotes. Commas are interpreted as delimiters, and parentheses can cause the deployment to fail. These cannot be used in environment variables.
Unescaped double quotes are either disregarded or will cause the rollout process to fail.
- For example:
"my_example_variable"will be applied as:
- If double quotes are inside of a string (e.g.
my_exampl"e_text), the rollout process will fail.
- To keep double quotes around a variable, escape them with a backslash (
\). For example:
\"my_example_var\"will be applied as:
- Double quotes inside strings can also be handled with escaping, so the rollout process can be completed. For example:
my_examp\"le_varwill be applied as:
In Build Settings
To add environment variables when adding your site, expand the Environment variables section, enter the key-value pairs.
To add environment variables after deployment, go to your site’s Settings page, scroll down to the Environment variables section, and click Add environment variable. Add the key-value pairs in the Add environment variable modal/pop-up window.