I am using Hugo to build 3 versions of a site: one for internal use, one for external use, and one for local, file-system access. Each one requires slightly different configurations. In an effort to avoid duplicating shared settings in 3 different config.toml files, I’m trying to use a single config.toml and pass in the specific commands that are different to our CI system at build time. I’m close to getting this to work, but I’m stuck with how to access parameters defined in my config.toml [params]
block.
Has anyone figured out how to access hugo [params]
from a command line?
For example, here is a simplified version of my config.toml file:
title = "Developer Portal"
theme = "theme-public"
[params]
internal = false
description = "Public site"
When I run the command below, the TITLE
and THEME
config settings are set correctly, but the INTERNAL
param is unchanged.
env HUGO_TITLE="Developer Portal - Internal build" HUGO_THEME="theme-internal" HUGO_PARAMS.INTERNAL=true hugo --cleanDestinationDir
I also tried a few different variations of the above without success. For example:
env HUGO_TITLE="Developer Portal - Internal build" HUGO_THEME="theme-internal" HUGO_PARAMS_INTERNAL=true hugo --cleanDestinationDir
I took a look at Viper, but I couldn’t figure out how to use it to solve this problem. Has anyone else tried to do something like this? If so, thanks for any tips!