Displaying two partials

Hey All,

I’m trying to display partials depending on if it matches the sites .Title or not but I dont seem to having much luck figuring why my code is not working.

{{ if .Title “Random Product” }}
{{ partial “shopify_black.html” . }}
{{ else }}
{{ partial “shopify_gold.html” . }}
{{ end }}

This is how I have my code setup. If anyone has a better suggestion or idea I’m open to them as well.

Hello @davicitoafc,

you’re very close to the finishing line. if STRING STRING does not return a boolean (true or false). So, how should if evaluate this “statement”?

You’ve to use eq (for equals) to check whether both strings are the same. If so, eq will return true which if can evaluate.

tldr:

{{ if eq .Title "Random Product" }}
...
1 Like