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

Support Hugo's built in build environment feature #574

Closed
jhenstridge opened this issue Sep 7, 2022 · 2 comments
Closed

Support Hugo's built in build environment feature #574

jhenstridge opened this issue Sep 7, 2022 · 2 comments

Comments

@jhenstridge
Copy link
Contributor

Hugo has built-in support for multiple build environments that is exposed to templates via the hugo.Environment and hugo.IsProduction variables. This is controlled via the --environment command line argument with the HUGO_ENV environment variable as a fallback.

Ananke has some support for build environments, but it does it by checking the HUGO_ENV environment variable directly:

{{ $production := eq (getenv "HUGO_ENV") "production" | or (eq site.Params.env "production") }}

This means Ananke's view of the build environment will match Hugo's if it was set by the environment variable but not if it was set via the command line.

It looks like this could be simplified to just using hugo.IsProduction. This would result in a change in behaviour when no environment is set at all. According to the docs, here are the results:

Default environments are development with hugo server and production with hugo.

@regisphilibert
Copy link
Member

Exactly, if we do this, then Ananke would treat any website with the default hugo command line as a production site. Any deploy preview etc... would be considered production.

It's an easy code change, but a difficult effort in communication to make sure everyone gets the memo.

@Juanpam
Copy link

Juanpam commented Sep 30, 2023

@regisphilibert I found this today! I'd say it would be worth it to document it at least as this theme is used in the getting started tutorial from Hugo. It can be confusing since it kinds of conflicts with what's specified in the docs.

BTW, I got the memo lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants