If..Else based on frontmatter possible?


I’ve seen examples of conditional statements based on Site.Params i.e. based on things written in config.toml

Is it possible to make a conditional based on each .md file frontmatter too? I’m trying to make an option enableComment : true, which, if not present should not display internal disqus comments.

This is my partials/custom-content-footer.html

 <footer class=" footline" >
	{{with .Params.LastModifierDisplayName}}
	    <i class='fa fa-user'></i> <a href="mailto:{{ $.Params.LastModifierEmail }}">{{ . }}</a> {{with $.Date}} <i class='fa fa-calendar'></i> {{ .Format "02/01/2006" }}{{end}}
	{{ partial "custom-comments.html" . }}

And this is partials/custom-comments.html

{{ template "_internal/disqus.html" . }}

What am I supposed to do?


You can wrap your Discus partial inside {{ with .Params.enableComment }}


An alternative is {{ if isset ...}}. I don’t recall the exact scenario, but I had an issue where I had false, but I think with counted that as set…

Go ahead and ignore this @siddhantrimal, unless with doesn’t work. :slight_smile: