mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2024-12-22 04:13:17 -06:00
Improve description wrapping in <head> metadata
This commit is contained in:
parent
240476061b
commit
179eda3450
@ -28,8 +28,8 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ partial "opengraph.html" . }}
|
{{ partial "opengraph.html" . }}
|
||||||
{{ template "_internal/twitter_cards.html" . }}
|
{{ partial "twitter_cards.html" . }}
|
||||||
{{ template "_internal/schema.html" . }}
|
{{ partial "schema.html" . }}
|
||||||
|
|
||||||
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<!-- See https://github.com/BBaoVanC/hugo/blob/opengraph-video-resources/tpl/tplimpl/embedded/templates/opengraph.html -->
|
<!-- See https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/opengraph.html -->
|
||||||
<meta property="og:title" content="{{ .Title }}" />
|
<meta property="og:title" content="{{ .Title }}" />
|
||||||
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
|
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary | plainify }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
|
||||||
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
|
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
|
||||||
<meta property="og:url" content="{{ .Permalink }}" />
|
<meta property="og:url" content="{{ .Permalink }}" />
|
||||||
|
|
||||||
|
26
layouts/partials/schema.html
Normal file
26
layouts/partials/schema.html
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<!-- See https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/schema.html -->
|
||||||
|
<meta itemprop="name" content="{{ .Title }}">
|
||||||
|
<meta itemprop="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary | plainify }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
||||||
|
|
||||||
|
{{- if .IsPage -}}
|
||||||
|
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
|
||||||
|
{{ with .PublishDate }}<meta itemprop="datePublished" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end}}
|
||||||
|
{{ with .Lastmod }}<meta itemprop="dateModified" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end}}
|
||||||
|
<meta itemprop="wordCount" content="{{ .WordCount }}">
|
||||||
|
|
||||||
|
{{- with $.Params.images -}}
|
||||||
|
{{- range first 6 . -}}<meta itemprop="image" content="{{ . | absURL }}">{{ end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $images := $.Resources.ByType "image" -}}
|
||||||
|
{{- $featured := $images.GetMatch "*feature*" -}}
|
||||||
|
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
||||||
|
{{- with $featured -}}
|
||||||
|
<meta itemprop="image" content="{{ $featured.Permalink }}">
|
||||||
|
{{- else -}}
|
||||||
|
{{- with $.Site.Params.images -}}<meta itemprop="image" content="{{ index . 0 | absURL }}"/>{{ end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
<!-- Output all taxonomies as schema.org keywords -->
|
||||||
|
<meta itemprop="keywords" content="{{ if .IsPage}}{{ range $index, $tag := .Params.tags }}{{ $tag }},{{ end }}{{ else }}{{ range $plural, $terms := .Site.Taxonomies }}{{ range $term, $val := $terms }}{{ printf "%s," $term }}{{ end }}{{ end }}{{ end }}" />
|
||||||
|
{{- end -}}
|
25
layouts/partials/twitter_cards.html
Normal file
25
layouts/partials/twitter_cards.html
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<!-- See https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/twitter_cards.html -->
|
||||||
|
{{- with $.Params.images -}}
|
||||||
|
<meta name="twitter:card" content="summary_large_image"/>
|
||||||
|
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
|
||||||
|
{{ else -}}
|
||||||
|
{{- $images := $.Resources.ByType "image" -}}
|
||||||
|
{{- $featured := $images.GetMatch "*feature*" -}}
|
||||||
|
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
||||||
|
{{- with $featured -}}
|
||||||
|
<meta name="twitter:card" content="summary_large_image"/>
|
||||||
|
<meta name="twitter:image" content="{{ $featured.Permalink }}"/>
|
||||||
|
{{- else -}}
|
||||||
|
{{- with $.Site.Params.images -}}
|
||||||
|
<meta name="twitter:card" content="summary_large_image"/>
|
||||||
|
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
|
||||||
|
{{ else -}}
|
||||||
|
<meta name="twitter:card" content="summary"/>
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end }}
|
||||||
|
<meta name="twitter:title" content="{{ .Title }}"/>
|
||||||
|
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary | plainify }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
|
||||||
|
{{ with .Site.Social.twitter -}}
|
||||||
|
<meta name="twitter:site" content="@{{ . }}"/>
|
||||||
|
{{ end -}}
|
Loading…
Reference in New Issue
Block a user