This seems like it should be so simple but can’t get it working… There is a environment variable set which prints out correctly when set. Tried various approaches but can’t seem to nail it… .any ideas?
{{ $dist_build := getenv "DIST_BUILD" }}
// {{ $dist_build }} - prints true/false based on setting.
{{ if $dist_build eq true }}
dist build
{{else}}
dev build
{{ end }}
Doesn’t getenv return a string? So, with eq, you would need to check if the value equals a string, not a boolean, right? Also, the eq needs to come before the two values that it is comparing. Using the bit below, I was able to run hugo server and get dev build and DIST_BUILD="true" hugo server and get dist build.
{{ $dist_build := getenv "DIST_BUILD" }}
{{ if eq $dist_build "true" }}
dist build
{{else}}
dev build
{{ end }}