Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hugo.Environment ignores HUGO_ENV used by Netlify and Forestry #6456

Open
gcushen opened this issue Oct 25, 2019 · 5 comments

Comments

@gcushen
Copy link

@gcushen gcushen commented Oct 25, 2019

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" }}
@bep

This comment has been minimized.

Copy link
Member

@bep bep commented Oct 25, 2019

You can use HUGO_ENVIRONMENT. Does the doc mention HUGO_ENV?

@gcushen

This comment has been minimized.

Copy link
Author

@gcushen gcushen commented Oct 25, 2019

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

@bep

This comment has been minimized.

Copy link
Member

@bep bep commented Oct 25, 2019

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

@gcushen gcushen changed the title BUG: `hugo.Environment` ignores `getenv "HUGO_ENV"` `hugo.Environment` ignores `getenv "HUGO_ENV"` used by Netlify and Forestry Oct 25, 2019
@gcushen gcushen changed the title `hugo.Environment` ignores `getenv "HUGO_ENV"` used by Netlify and Forestry hugo.Environment ignores HUGO_ENV used by Netlify and Forestry Oct 25, 2019
@gcushen

This comment has been minimized.

Copy link
Author

@gcushen gcushen commented Oct 25, 2019

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.

@gcushen

This comment has been minimized.

Copy link
Author

@gcushen gcushen commented Oct 25, 2019

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?

gcushen added a commit to gcushen/hugo-academic that referenced this issue Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.