Alternative Partials

I’m still not fluent in HTML/JS/Go etc.

Would someone kindly tell me, is it possible to place a variable in the front matter of a page, such as:

codeB = true

So that in the partial sidebar.html I can place something like:

IF codeB = true THEN { the HTML code version B to be rendered } ELSE { the HTML code version A to be rendered }

I would like some pages to have a slightly modified sidebar. [If I’ve got it right first time - I’ll post it as a tip!]

Yes. Go templates support if/else logic.

{{ if eq .Params.codeb "blog" }}blah{{ else }}bleh{{ end }}

Please look at for some examples. You’ll want to review the “isset” function if you don’t plan on setting the variable on every page. In face, if you’re treating codeB as a boolean, the isset is much better than the “eq”.

Thank you @michael.henderson. It worked like a dream using eq and values “yes” or “no” for codeB.

I tried isset but got into a mess over whether boolean values were “true” or true and “false” or false. But it’s been a long day and I decided not to fight it.

Bonus: using the same technique in the footer I’ve been able to stop Disqus rendering in pages where it’s inappropriate.