hugo.Environment ignores HUGO_ENV used by Netlify and Forestry

Created on 25 Oct 2019  路  6Comments  路  Source: gohugoio/hugo

What version of Hugo are you using (hugo version)?

v0.58.1

Does this issue reproduce with the latest release?

Yes

Problem

There are at least two ways to set the environment to development or production in Hugo.

Many users are reporting very confusing behavior to us in the way that hugo.Environment ignores HUGO_ENV.

Surely, the following statement should be true if either HUGO_ENV="production" or if the -e production argument is provided, otherwise this behavior can be very confusing to users:

{{ if eq (hugo.Environment) "production" }}
Enhancement

Most helpful comment

FYI GitHub states that there are currently ~16,500 files (very rough max. proxy for sites) using the HUGO_ENV approach.

Whereas there are only ~17 files on GitHub containing HUGO_ENVIRONMENT.

Perhaps you might find the above compelling enough to listen to the community on this one and warrant supporting HUGO_ENV as an environment?

All 6 comments

You can use HUGO_ENVIRONMENT. Does the doc mention HUGO_ENV?

Thanks for clarifying.

It appears that both Netlify and Forestry use HUGO_ENV though, so it would be logical either they use HUGO_ENVIRONMENT or Hugo begins to understand HUGO_ENV as the Hugo.Environment?

See

You could start by removing the big BUG in the title, then, as this is obviously not that.

Currently, the official Hugo website only appears to mention HUGO_ENV (in the link above) and not HUGO_ENVIRONMENT, hence it appeared to be a bug. Thanks for clarifying that it's an inconsistent use of environment within the community, and I've updated the title to reflect that :)

I assume it would be beneficial to support HUGO_ENV as an environment in Hugo since a large number of Hugo powered Netlify and Forestry sites already use this approach.

FYI GitHub states that there are currently ~16,500 files (very rough max. proxy for sites) using the HUGO_ENV approach.

Whereas there are only ~17 files on GitHub containing HUGO_ENVIRONMENT.

Perhaps you might find the above compelling enough to listen to the community on this one and warrant supporting HUGO_ENV as an environment?

+1 for supporting HUGO_ENV.

Was this page helpful?
0 / 5 - 0 ratings