gohugo-theme-ananke icon indicating copy to clipboard operation
gohugo-theme-ananke copied to clipboard

Update build environment logic

Open tlindsay42 opened this issue 3 years ago • 4 comments

Closes #453 Relates to #457

  • Adds GetEnvironmentName and IsProduction partial functions, which improve DRY
  • Add prioritization for determining environment name, which favors the existing methods: the HUGO_ENV environment variable and site config env theme parameter
  • Adds useHugoEnv theme parameter to use the value of .Hugo.Environment for the build environment name

tlindsay42 avatar Jan 03 '22 19:01 tlindsay42

Ready for review @regisphilibert

tlindsay42 avatar Jan 03 '22 19:01 tlindsay42

Thanks @tlindsay42 for all you work this past weeks 🙏 . I feel like this one deserves some thinking though. JFY, we're not ignoring it but might ponder it for some time.

regisphilibert avatar Jan 10 '22 20:01 regisphilibert

Sounds good. My primary driver for this feature was that I chose to implement my site with the env-specific config files (eg: ./config/_default/config.toml and ./config/production/config.toml) because I wanted to define a few env-specific behaviors, such as minification. Given this, I was confused at first when parts of the site ran in production mode when I ran hugo server --environment production, but other features didn't.

To test production mode with this type of implementation, customers have to potentially set both the environment variable and the argument, which isn't that big of a deal, but imo it's annoying and not obvious.

Since the feature is opt-in only, existing customers that aren't expecting this won't be impacted (like we previously discussed).

I'm open to suggestions if changes are desired.

I hope you decide to merge it, but understand if the decision is otherwise. Thanks!

tlindsay42 avatar Jan 10 '22 21:01 tlindsay42

+1. I just started using this theme and was confused by the --environment option not being sufficient.

rgson avatar May 29 '22 18:05 rgson