I’d like to know if it is possible to set a Site.Params
value from the command line.
The reason: I have a version number for my software which I would like to include into the hugo generated documentation (see https://doc.speedata.de/publisher/de/ at the top).
If it is not possible to set a value for Site.Params
: is there an alternative approach? I have tried to override the parameter with an environment variable, but I ran into the same issues as discussed in How to access config [params] map from command line.
I just use sed
(on GNU/Linux, Mac and *nix systems).
If you have this in config.toml
:
[params]
foo = 1
And you want to change the foo
variable, do:
sed -i.bkp 's/foo =.*/foo = "NEW VAL"/' config.toml
sed
and such are a lost art worth learning even for web dev.
Thanks, @kaushalmodi
the sed approach has the side effect that the file changes from the version control’s view (although there are mechanisms to ignore the change etc.)
I’d actually do that on the CI/CD itself, e.g. Netlify command
parameter.
You can also choose to do that AND have multiple config files:
… keep a main config file that you version control, and another that you don’t, that you create/modify on the fly (You would do the same on CI/CD too; the benefit being that you don’t need to alter-then-restore the main config file before committing.)