summaryrefslogtreecommitdiffstats
path: root/layouts/partials
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/partials')
-rw-r--r--layouts/partials/description.html15
-rw-r--r--layouts/partials/head.html7
-rw-r--r--layouts/partials/templates/opengraph.html2
3 files changed, 17 insertions, 7 deletions
diff --git a/layouts/partials/description.html b/layouts/partials/description.html
new file mode 100644
index 0000000..e63c0d9
--- /dev/null
+++ b/layouts/partials/description.html
@@ -0,0 +1,15 @@
+{{- $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 -}}
+
+{{- $description | plainify | safeHTML | chomp | truncate 180 -}}
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index abb4cbe..478410a 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -1,10 +1,5 @@
{{/* */}}
<head>
- {{- $description := print .Params.Description -}}
- {{- if or .IsHome (eq .Params.Description "") (not .Params.Description) -}}
- {{ $description = site.Params.Description }}
- {{- end -}}
-
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1.0,shrink-to-fit=no">
@@ -13,7 +8,7 @@
<link type="text/plain" rel="author" href="{{ "humans.txt" | absURL }}">
<title>{{ block "title" . }}{{ if .IsHome }}{{ site.Title }}{{ else }}{{ with .Params.Title }}{{ . }} - {{ end }}{{ site.Title }}{{ end }}{{ end }}</title>
- <meta name="description" content="{{ $description }}">
+ <meta name="description" content="{{ (partial "description.html" . ) }}">
<meta name="author" content="{{ (partial "author.html" . ) }}">
{{ hugo.Generator }}
diff --git a/layouts/partials/templates/opengraph.html b/layouts/partials/templates/opengraph.html
index c94fd68..3b9fb36 100644
--- a/layouts/partials/templates/opengraph.html
+++ b/layouts/partials/templates/opengraph.html
@@ -1,6 +1,6 @@
<!-- Open Graph metadata -->
<meta property="og:title" content="{{ .Title }}">
- <meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ replaceRE "\n" " " (.Summary | truncate 170) }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
+ <meta property="og:description" content="{{ (partial "description.html" . ) }}">
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
<meta property="og:url" content="{{ .Permalink }}">
{{- if .Params.cover.image -}}