Handle optional variables in header

Handle optional variables such as "subtitle" and "bigimg" in header to
avoid errors when these variables are not set.
This commit is contained in:
Michael Romero 2017-03-20 23:52:48 -07:00
parent ee6246379b
commit 3e2b5c77dd

View File

@ -1,11 +1,11 @@
{{ if .IsHome }}
{{ $.Scratch.Add "bigimg" .Site.Params.bigimg }}
{{ $.Scratch.Add "title" .Site.Title }}
{{ $.Scratch.Add "subtitle" .Site.Params.subtitle }}
{{ if .Site.Params.subtitle }}{{ $.Scratch.Add "subtitle" .Site.Params.subtitle }}{{ end }}
{{ if .Site.Params.bigimg }}{{ $.Scratch.Add "bigimg" .Site.Params.bigimg }}{{ end }}
{{ else }}
{{ $.Scratch.Add "bigimg" .Params.bigimg }}
{{ $.Scratch.Add "title" .Title }}
{{ $.Scratch.Add "subtitle" .Params.subtitle }}
{{ if .Params.subtitle }}{{ $.Scratch.Add "subtitle" .Params.subtitle }}{{ end }}
{{ if .Params.bigimg }}{{ $.Scratch.Add "bigimg" .Params.bigimg }}{{ end }}
{{ end }}
{{ $bigimg := $.Scratch.Get "bigimg" }}