all repos — archie @ 117808b653817e8ff7c7fc747361d2227de07a82

A minimal Hugo Theme

Improve meta description

Rather than use the same description on every page, prefer the post
summary if it's available and only use .Params.description on the root
page.

This mimics the behavior of the [opengraph internal
template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/opengraph.html#L2)
for the `og:description` tag.
David Wittman dave@wittman.xyz
Sat, 22 May 2021 10:54:55 -0500
commit

117808b653817e8ff7c7fc747361d2227de07a82

parent

1f47eeb7bedefd8fee4d8bae7072766cfa2219ad

1 files changed, 1 insertions(+), 3 deletions(-)

jump to
M layouts/partials/header.htmllayouts/partials/header.html

@@ -14,9 +14,7 @@ <link rel="icon" type="image/png" href={{ .Site.Params.favicon }} />

{{- end -}} <meta name="viewport" content="width=device-width, initial-scale=1"> - {{- if isset .Site.Params "description" }} - <meta name="description" content="{{ .Site.Params.description }}" /> - {{- end }} + <meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" /> <meta property="og:image" content="{{ .Site.Params.og_image }}"/> {{ with .OutputFormats.Get "rss" -}} {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}