[go: nahoru, domu]

Skip to content

Commit

Permalink
Improve meta description
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DavidWittman authored and athul committed May 22, 2021
1 parent 1f47eeb commit 117808b
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
{{- 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 }}
Expand Down

0 comments on commit 117808b

Please sign in to comment.