I’m looking for best practices when checking for a Hugo feature existence.
For exemple .Resources has been introduced in .32 but .Resources.Match in .34
For many CI host out there, you can choose your version of Hugo.
I really want to test drive Forestry.io which for some reason won’t let you use the most recent version of Hugo, (they’re stuck at 31.1, soon .32) even if you only need them to commit to your repo and not build/deploy…
Si I have to make sure, my code can use the latest Hugo features on Netlify but stay away from them in Forestry.
I could play around with isset and nested conditions, but I’d rather not push/deploy too much on the repo waiting for Forestry to give me a green badge…
Couldn’t you just wget or curl the latest hugo from Releases and directly use that? I do something like that (actually use my latest DEV build of hugo) on Netlify.
That is if you can choose the version. I’m talking about cases where you can’t. Like building a theme for exemple or working with CI imposing its own version like Forestry.
Isn’t this about writing hugo templates with fallbacks, if a feature is not available?
E.g. a theme author does not know which hugo version a project uses.
There is
min_version = "0.30.2"
in theme.toml
but this is only for published themes… EDIT: theme.toml is for any theme - see @bep’s answer below
.Hugo.Version
the current version of the Hugo binary you are using
I understand all this. But it means building a theme for a certain version of Hugo and getting stuck with it if you don’t want to break your users current theme.
You can’t suddenly bump your min_version without risk.
Never the less the .Hugo.Version check is quiet enough for now I suppose.