Multiple single site based on one content file with conditional parts

Hi!
I have the following scenario: I am writing a documentation for a product. The whole text is within one content file (markdown). This product now has different editions, so the documentation could slightly differ partially. One sentence / illustration here and there.
I want to have one content markdown file with conditional blocks, and I want to generate multiple single page from this one content file, displayed in the same site.
Could anyone give me help with this?

I already created a conditional shortcode which uses a params value. So if I set a specific parameter in the config file, I can generate different sites from one content with conditional blocks in the content markdown.
This is my conditional shortcode template:

{{ if (eq (trim (index .Site.Params (.Get 0)) " " | lower) (.Get 1)) | and (isset .Site.Params (.Get 0)) }}
    {{ .Inner  }}    
{{ end }}

Could be used like this:

{{% condtext edition a %}}
    Content only appearing, if config.toml  has edition = "a" in params.
{{% /condtext %}}

Thank you for your guidance and help!

This was uncategorized, so I’m not sure where it goes. Did you have a question? Is this a tip to others? If you need support, please read Requesting Help and use question marks. :slight_smile:

Thanks! :blush:
I am asking for help, asking for direction, how to proceed with this.

Right now what I have figured out, is to use the translations feature to have different versions on one site, use the conditionals in the content file - this I shared in the OP, and symlink the content file to a translation content file. The paramters are given to the content file from the translations section in the site config.

1 Like

I am looking at doing something similar to this, and my question is whether I’m going about this the right way or if there is a better way.

What I have is a single content collection, with multiple potential audiences. For now, I’ll keep it simple. I am writing tutorials and that sort of documentation which are specific to my organization but I would like to be able to publish articles for a public audience from the same base, by marking off content appropriately.

What I have so far is a solution similar to @szlrd’s use of shortcodes. I’ve got this in the content:

This is generic information which would apply to all situations, probably including yours, but doesn't provide specifics because I don't know your environment.

{{% audience intranet %}}
Here in our organization, we can use _this technology_ or _that_ and etc.
{{% /audience %}}

In the above snippet, the intention is that the first paragraph would wind up on the public site and the second paragraph would only appear on the intranet documentation site. (It would maybe be preferable that public stuff has to be specifically marked as such, to err on the side of privacy, but that’s more complicated.)

The shortcode is defined as such:

{{ if eq $.Page.Site.Params.audience ( .Get 0 ) }}
   {{ .Inner }}
{{ end }} 

There does not seem to be a way to specify configuration variables on the command line, so I use multiple configuration files to generate the various sites. Here is the full contents of config-internal.toml:

[params]
audience = "internal"

And then Hugo is invoked as (the server in this case):

hugo --config=config.toml,config-internal.toml server -D

I have also used -e internal and tested for that, but it seems like the wrong use of that facility, and a less flexible approach.

Originally I looked for a way to specify parameters on the command line, which would be handy for my purposes, but seems to work okay.

So my question is, is there a better, more Hugo-ish way to achieve what I have described?

Thanks all, and sorry to the OP if I’ve hijacked your question.