Customized build with Hugo

Hey there,

I’ve been searching for a while but I could not find any resources to drive me toward my goal with Hugo. Let me explain my needs.

I need to build a generic landing page in which I’ll have three different builds for three different customers. The landing page is almost identical to each one, the differences are some background images and some customer specific texts in the page.

I think that it could be done by using some kind of dynamic parameters within the build process, maybe selecting a different config on build time, but I could not find a way to do that. I would like to know if this can be done with Hugo or if you have any resources I could use it to accomplish it.

Thanks,

Please read all the pages in the docs. The Configure Hugo | Hugo doc is particularly relevant. :slight_smile:

Hi @maiki, off course I searched the docs before opening this topic :face_with_raised_eyebrow:. and once again: I couldn’t find nothing addressing my specific need.

If you could guide me any other resources I would appreciate that.

Thanks,

If you visit the docs linked by @maiki above, there is an example of overriding the default config. For your use case, say something like:

hugo --config customer-1.toml
2 Likes

Yeah, You are right sorry for the miss @maiki, and thanks again, also thanks @zwbetz

Another option is to dynamically change your build based on an environment variable:

1 Like

Any reason why you would not want to keep distinctly separate file system locations for each site for the sake of simplicity? Then run hugo and other deployment commands in a batch process? Maybe I am missing the advantages of “dynamic config” in this case.

If the website is in 3 places, then when you want to make a change, you have to make 3 changes. If using multiple config files, you only have to make the change in 1 file.

1 Like

Still don’t see the advantage given the added complexity.

If you make a change, you would make the change in one file and copy it to the other 2 places.

If all the files are in one location serving 3 sites, how could you know within that directory which files are associated to which site?

Either way there would be multiple config files to maintain.

Would making a change and then having to copy it to 2 other places not be considered added complexity?

If I am understanding you correctly, you would know this by the name of the config file. For example:

customer-1.toml
customer-2.toml
customer-3.toml

Also, one could have a base config file with common options, e.g. baseconfig.toml, then the customer config files would only contain customer-specific options. Then you could do something like this:

hugo --config baseconfig.toml, customer-1.toml
2 Likes

I realize each site would have a separate config file.

But in a single location multi config setup there would be different images and customer specific texts intermingled with the non-customer specific files. This would have to be managed such that you knew which files belonged to which site. Which seems more complicated than having separate sites all together.

I will read some more and try to understand what benefits a multi config setup brings.

I am glad the original poster is satisfied!

I was under the assumption that the background image paths and the customer-specific texts would live in the config files. I could be wrong.

if the bg images live in /static, you can set different directories for every customer in the config file
look at https://gohugo.io/getting-started/configuration/