HUGO
Menu
GitHub 90498 stars Mastodon

hugo.Environment

Returns the current running environment.
Syntax
hugo.Environment
Returns
string

Usage

The hugo.Environment function returns the current running environment. Set the environment with the --environment command-line flag or the HUGO_ENVIRONMENT environment variable. If you set both, the flag takes precedence. If you set neither, the environment is development when you run the hugo server command, and production otherwise.

This table shows the environment returned by the function for each command:

CommandEnvironment
hugo buildproduction
hugo build --environment stagingstaging
HUGO_ENVIRONMENT=staging hugo buildstaging
HUGO_ENVIRONMENT=staging hugo build --environment productionproduction
hugo serverdevelopment
hugo server --environment stagingstaging

Examples

{{ hugo.Environment }} → production