Environment Variables

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.

Special Characters in Environment Variables

In the environment variable keys, you can only use a-z, 0-9, or underscore (_). Environment variable values are applied literally, with the exception of parentheses, commas, and double quotes.

Parentheses

Parentheses can cause the build and rollout process to fail. They cannot be used in environment variables.

Commas

Unescaped commas are interpreted as delimiters and cannot be used in environment variables.

  • For example: write_stock,read_orders will cause the rollout process to fail.
  • To keep a comma inside a string, escape it with a backslash (\) like this: write_stock\,read_orders — which will be applied as write_stock,read_orders.

Double Quotes

Unescaped double quotes are either disregarded or will cause the rollout process to fail.

  • For example, "my_example_variable" will be applied as my_example_variable.
  • To keep double quotes around a variable, escape them with a backslash (\) like this: \"my_example_var\" — which will be applied as "my_example_var".
  • If double quotes are inside of a string (e.g. my_exampl"e_text), the rollout process will fail.
  • To keep double quotes inside a string, escape them with a backslash (\) like this: my_examp\"le_var — which will be applied as my_examp"le_var.

Adding Environment Variables

Environment variables can be added in the Build settings step when adding a static site or on your site’s Settings page after deployment.

In Build Settings

To add environment variables when adding your site, expand the Environment variables section and enter the key-value pairs.

After Deployment

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.

Editing Environment Variables

You can edit variable names (keys) or values on the Settings page. To edit a variable, click the Edit (pencil) icon, make your changes, and click Save changes.