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

Closed
gcushen opened this issue Oct 25, 2019 · 7 comments
Closed

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

gcushen opened this issue Oct 25, 2019 · 7 comments

Comments

@gcushen
Copy link

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
Copy link
Member

bep commented Oct 25, 2019

You can use HUGO_ENVIRONMENT. Does the doc mention HUGO_ENV?

@gcushen
Copy link
Author

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
Copy link
Member

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
Copy link
Author

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
Copy link
Author

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?

@ianrodrigues
Copy link

+1 for supporting HUGO_ENV.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants