From c65715725ee992cd4e59aeefe0f66df80b2eb4ea Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Sat, 9 Jul 2022 11:50:15 -0400 Subject: [PATCH] Generate page meta-description like Hugo --- layouts/partials/head.html | 3 +-- layouts/partials/page-description.html | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 layouts/partials/page-description.html diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 2d95400f65..63cd432b87 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -21,8 +21,7 @@ {{ .Site.Title -}} {{ end -}} -{{ $desc := .Page.Description | default (.Page.Content | safeHTML | truncate 150) -}} - + {{ template "_internal/opengraph.html" . -}} {{ template "_internal/schema.html" . -}} {{ template "_internal/twitter_cards.html" . -}} diff --git a/layouts/partials/page-description.html b/layouts/partials/page-description.html new file mode 100644 index 0000000000..3529fbe611 --- /dev/null +++ b/layouts/partials/page-description.html @@ -0,0 +1,11 @@ +{{ with .Description | plainify -}} + {{ . -}} +{{ else -}} + {{ if .IsPage -}} + {{ .Summary | plainify | chomp -}} + {{ else -}} + {{ with .Site.Params.description | plainify -}} + {{ . -}} + {{ end -}} + {{ end -}} +{{ end -}}