gohugo-theme-ananke
gohugo-theme-ananke copied to clipboard
Update build environment logic
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 configenv
theme parameter - Adds
useHugoEnv
theme parameter to use the value of.Hugo.Environment
for the build environment name
Ready for review @regisphilibert
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.
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!
+1. I just started using this theme and was confused by the --environment
option not being sufficient.