summaryrefslogtreecommitdiffstats
path: root/layouts/partials/description.html
blob: b2100a86b6816666d7eb67b1a2d7bdfcfe824117 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{{- $description := "" -}}

{{- if .IsHome -}}
    {{- $description = site.Params.Description -}}
{{- else -}}
    {{- if and (.Params.Description) (ne .Params.Description "") -}}
        {{- $description = print .Params.Description -}}
    {{- else if and (.Params.Summary ) (ne .Params.Summary "") -}}
        {{- $description = print .Params.Summary -}}
    {{- else -}}
        {{- $description = print .Summary -}}
    {{- end -}}
{{- end -}}

{{- /* Meta descriptions can technically be any length, but Google generally
    truncates snippets to ~155-160 characters. It's best to keep meta descriptions
    long enough that they're sufficiently descriptive, so we recommend descriptions
    between 50 and 160 characters. */ -}}
{{- replaceRE "\n" " " ($description | plainify | safeHTML | chomp | truncate 160) -}}