So, I’m trying to set page title based on a condition. Since I need to include the same title in properties like og:title, etc. I was thinking, maybe, I could store the title in a variable ({{ .Scratch}}).
It’s working correctly except for the fact that in the both the else conditions, it’s setting title as Projects tagged {{ .Title }} | {{ .Site.Params.Title }} as-is. The {{ .Title }} and {{ .Site.Params.Title }} are not getting substituted with the expected values.
I’ve to do something similar for description, so, it’ll be helpful to set it once and access it multiple times.
P.S.: currentPage has been setup like this: {{ .Scratch.Set "currentPage" .Permalink}}
Yeah I do, that’s why I wanted to know the alternative route to do this. I just thought that showing what I tried (basically, what I could think of trying) would be better than asking people to help without me trying anything.
{{ .Scratch.Set "title" (printf "%s | %s" .Title .Site.Params.Title) }} Basically, all variables after the text in "...". So, I’m guessing %s is what defines where the strings will be placed.