I have the following in my partials/header.html:
<meta name="description" content="{{if .IsHome}}{{.Site.Params.description}}{{end}}{{if .Description}}{{.Description}}{{end}}
{{if .Params.about}}{{.Params.about}}{{else}}{{.Params.name}} {{delimit .Params.location " "}}
{{delimit .Params.apple " "}} {{delimit .Params.banana " "}}
{{delimit .Params.pear " "}} {{delimit .Params.kiwi " "}}
{{.Params.pineapple}}{{end}}">
Unfortunately it doesn’t work as I would like and the template looks really messy with this logic.
What I’m trying to accomplish is to set the meta description depending upon the following:
-
IF homepage ->
<meta name="description" content="{{.Site.Params.description}}">
-
IF NOT homepage AND .Params.description -> .Params.description
<meta name="description" content="{{.Params.description}}">
-
IF NOT homepage AND NOT .Params.description AND .Params.about -> .Params.about
<meta name="description" content="{{.Params.about}}">
-
IF NOT homepage AND NOT .Params.description AND NOT .Params.about ->
<meta name=“description” content="{{.Params.name}} {{delimit .Params.location " "}}
{{delimit .Params.apple " "}} {{delimit .Params.banana " "}}
{{delimit .Params.pear " "}} {{delimit .Params.kiwi " “}}
{{.Params.pineapple}}”>
Changing the way that the Params are declared in the frontmatter isn’t an option.