Open navClose nav

Environments

There are three unique developer environments when working with a Hugo site in Forestry:

  • Local environment this is your local development environment on your own machine. See Local Development for more info.

  • Staging environment this is the environment Forestry creates when we generate a preview for you. See Previews for more info.

  • Production environment this is the environment your site is published to. See Hosting Options for more info.

In order to make development easier, Forestry sets the environment variable HUGO_ENV based on the environment you’re in.

This allows you to set up conditional code in your layouts in order to handle paths, content, or functionality dependent on a specific environment.

This variable is accessible in your templates with the getenv function:

{{ getenv "HUGO_ENV" }}

The values are:

  • Local environment: development
  • Staging environment: “staging”
  • Production environment: “production”

Note: in Hugo the local environment variable is undefined because Hugo does not set this environment variable by default. You can also use hugo.Environment and hugo.IsProduction in your templates.


Last updated on July 24, 2017