Lego2012
6/12/2017 - 7:44 PM

site-header.html Example

site-header.html Example

{{ $featured_image := .Params.featured_image }}
{{ if $featured_image }}
    {{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}}
    {{ $featured_image := (trim $featured_image "/") | absURL }}
    <header style="background-image: url('{{ $featured_image }}');">
        <div>
            {{ partial "site-navigation" .}}
            <div>
                <h1>
                    {{ .Title | default .Site.Title }}
                </h1>
                {{ with .Params.description }}
                    <h2>
                        {{ . }}
                    </h2>
                {{ end }}
            </div>
        </div>
    </header>
{{ else }}
    <header>
        <div class="{{ .Site.Params.background_color_class | default "bg-black" }}">
            {{ partial "site-navigation" . }}
            <div>
                <h1>
                    {{ .Title | default .Site.Title }}
                </h1>
                {{ with .Params.description }}
                    <h2>
                        {{ . }}
                    </h2>
                {{ end }}
            </div>
        </div>
    </header>
{{ end }}