What is the best way to create a variant of my site?

I am using Hugo to produce help documentation for my company’s product. We have recently created an alternative version of the product which retains most of the same help content but with an alternative product name.

My solution so far has been to create a theme for each variant and a shortcode that can be used as a placeholder for the product name.

Unfortunately I cannot find a way to modify the titles (and menu structure) in the front-matter using this same variable.

Is there a best practice way to solve this? I really love the hugo serve live-reload capability so pre-processing the .md or post-processing the .html is not an attractive option…

May be the replaceRE template function can help here.

Update: Some elaboration. I would set the project name as some unique string like PROJECT_NAME which you are sure won’t be used in any other context. Then use replaceRE to replace that string with the value in something like .Site.Params.projectname.

As a side, my solution would be to instead use Org macros (my site sources are in Org mode instead of Markdown).

I am not clear on how to use replaceRE in the front-matter. Can you give an example?

You would use that in your layout… probably where you insert .Content… so {{ .Content | replaceRE ... }}. Or if you want to replace just titles, then {{ .Title | replaceRE ... }}… and then similar replacement where you generate the menus.

If you share the source and explain what exact strings you need to replace, someone can provide a better help.

Thank you for the clarification, I started to pepper my templates and partials with:

{{ .Title | replaceRE "@product@" .Site.Params.productName }}

Which worked well for the templates but not so well for the partials.

My next approach is to create a partial like this:
{{ (replaceRE "@product@" .site.Params.productname .input) | markdownify }}

Which I can call like this:
<h1>{{ partial "productize.html" (dict "input" .Title "site" .Site) }}</h1>

Two oddities so far:

  1. .Params.productName becomes .Params.productname after I pass it in the dict
  2. I can’t use .Content as the input unless I pass the result of replaceRE to markdownify

I would welcome any suggestions on a more elegant solution!