Conditionally rendering while markdown file

There is a front matter variable called ‘draft’ to decide the current md file will be rendered as a web page or not.

But I have 2 versions of website for internal and outernal readers, both of them share the same Hugo project with different configurations.

for internal readers, I want front matter variable ‘draft’ set to false , so they can see this page.

for outernal readers, I want front matter variable ‘draft’ set to true , so they can not see this page.

I add an additional variable in params.toml called ‘site_name’ , whose value is ‘internal’ for internal reader’s website, and ‘outernal’ for outernal reader’s website.

So how to set front matter variable ‘draft’ to different value by site param variable?

Or are there other good solutions?


More info: We plan to have another version only for site maintainers, so totally we will have more than 2 versions. For time being there are 3 versions.

Some pages only for maintainers, some pages only for internal readers. That could not be solved just by build switch ‘–buildDrafts’

When you build the internal version, tell Hugo to include drafts See Hugo CLI docs for the attribute to use.

1 Like

@frjo,

Thanks, that does the trick.

But, we plan to have another version only for site maintainers, so totally we will have more than 2 versions. For time being there are 3 versions.

Some pages only for maintainers, some pages only for internal readers. That could not be solved just by one build switch.

Any other solutions?