From 7a0757cef79a42e9d50e31f59e681b0b0d7b7d80 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sat, 20 Nov 2021 18:24:56 -0600 Subject: [PATCH] Rewrite meta tag partials --- layouts/partials/head.html | 11 ++-- layouts/partials/link_tags.html | 15 +++++ layouts/partials/opengraph.html | 89 ++++++++++++++--------------- layouts/partials/schema.html | 42 +++++++------- layouts/partials/twitter_cards.html | 42 ++++++-------- 5 files changed, 99 insertions(+), 100 deletions(-) create mode 100644 layouts/partials/link_tags.html diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 88f9f8c..f7a10e9 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -20,10 +20,6 @@ {{ end }} - {{ range .AlternativeOutputFormats -}} - {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} - {{ end -}} - {{ if .IsHome }} {{ .Site.Title }} {{ else }} @@ -33,8 +29,9 @@ {{ partial "opengraph.html" . }} {{ partial "twitter_cards.html" . }} {{ partial "schema.html" . }} - - - + {{ partial "link_tags.html" . }} {{ partial "author-metadata.html" . }} + + + diff --git a/layouts/partials/link_tags.html b/layouts/partials/link_tags.html new file mode 100644 index 0000000..89b00f9 --- /dev/null +++ b/layouts/partials/link_tags.html @@ -0,0 +1,15 @@ +{{ range .AlternativeOutputFormats }} + +{{ end }} +{{ with .OutputFormats.Get "rss" }} + +{{ end }} + +{{ with .PrevInSection }} + +{{ end }} +{{ with .NextInSection }} + +{{ end }} + + diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html index d036161..7b7b351 100644 --- a/layouts/partials/opengraph.html +++ b/layouts/partials/opengraph.html @@ -1,53 +1,48 @@ - - - - - + + + + -{{- with $.Params.images -}} -{{- range first 6 . }}{{ end -}} -{{- else -}} -{{- $images := $.Resources.ByType "image" -}} -{{- $featured := $images.GetMatch "*feature*" -}} -{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} -{{- with $featured -}} - -{{- else -}} -{{- with $.Site.Params.images }}{{ end -}} -{{- end -}} -{{- end -}} +{{ $images := $.Resources.ByType "image" }} +{{ $featured := $images.GetMatch "*feature*" }} +{{ if not $featured }} + {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }} +{{ end }} -{{- if .IsPage }} -{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} - -{{ with .PublishDate }}{{ end }} -{{ with .Lastmod }}{{ end }} -{{- end -}} +{{ with $featured }} + +{{ end }} -{{- with .Params.audio }}{{ end }} -{{- with .Params.locale }}{{ end }} -{{- with .Site.Params.title }}{{ end }} +{{ with .Section }} + +{{ end }} -{{- with .Params.videos -}} -{{- range first 6 . }}{{ end -}} -{{- else -}} -{{- $videos := $.Resources.ByType "video" -}} -{{- $featured_video := $videos.GetMatch "*feature*" -}} -{{- if not $featured_video }}{{ $featured_video = $videos.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} -{{- with $featured_video -}} - -{{- end -}} -{{- end -}} +{{ $format := "2006-01-02T15:04:05-07:00" }} +{{ with .Date }} + +{{ end }} +{{ with .Lastmod }} + +{{ end }} -{{- /* If it is part of a series, link to related articles */}} -{{- $permalink := .Permalink }} -{{- $siteSeries := .Site.Taxonomies.series }} -{{ with .Params.series }}{{- range $name := . }} - {{- $series := index $siteSeries ($name | urlize) }} - {{- range $page := first 6 $series.Pages }} - {{- if ne $page.Permalink $permalink }}{{ end }} - {{- end }} -{{ end }}{{ end }} +{{ with .Params.audio }} + +{{ end }} -{{- /* Facebook Page Admin ID for Domain Insights */}} -{{- with .Site.Social.facebook_admin }}{{ end }} +{{ with .Language.Lang }} + +{{ end }} + +{{ with .Site.Params.title }} + +{{ end }} + +{{ $videos := $.Resources.ByType "video" }} +{{ $featured_video := $videos.GetMatch "*feature*" }} +{{ if not $featured_video }} + {{ $featured_video = $videos.GetMatch "{*cover*,*thumbnail*}" }} +{{ end }} + +{{ with $featured_video }} + +{{ end }} diff --git a/layouts/partials/schema.html b/layouts/partials/schema.html index fb55d95..0363383 100644 --- a/layouts/partials/schema.html +++ b/layouts/partials/schema.html @@ -1,26 +1,26 @@ - - + + +{{ $format := "2006-01-02T15:04:05-07:00" }} +{{ with .Date }} + +{{ end }} +{{ with .Lastmod }} + +{{ end }} -{{- if .IsPage -}} -{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} -{{ with .PublishDate }}{{ end}} -{{ with .Lastmod }}{{ end}} -{{- with $.Params.images -}} -{{- range first 6 . -}}{{ end -}} -{{- else -}} -{{- $images := $.Resources.ByType "image" -}} -{{- $featured := $images.GetMatch "*feature*" -}} -{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} -{{- with $featured -}} - -{{- else -}} -{{- with $.Site.Params.images -}}{{ end -}} -{{- end -}} -{{- end -}} +{{ $images := $.Resources.ByType "image" }} +{{ $featured := $images.GetMatch "*feature*" }} +{{ if not $featured }} + {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }} +{{ end }} - - -{{- end -}} +{{ with $featured }} + +{{ end }} + +{{ with .Params.tags }} + +{{ end }} diff --git a/layouts/partials/twitter_cards.html b/layouts/partials/twitter_cards.html index 36bcca7..5fa93c9 100644 --- a/layouts/partials/twitter_cards.html +++ b/layouts/partials/twitter_cards.html @@ -1,25 +1,17 @@ - -{{- with $.Params.images -}} - - -{{ else -}} -{{- $images := $.Resources.ByType "image" -}} -{{- $featured := $images.GetMatch "*feature*" -}} -{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} -{{- with $featured -}} - - -{{- else -}} -{{- with $.Site.Params.images -}} - - -{{ else -}} - -{{- end -}} -{{- end -}} -{{- end }} - - -{{ with .Site.Social.twitter -}} - -{{ end -}} +{{ $images := $.Resources.ByType "image" }} +{{ $featured := $images.GetMatch "*feature*" }} +{{ if not $featured }} + {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }} +{{ end }} + +{{ with $featured }} + + +{{ end }} + + + + +{{ with .Site.Social.twitter }} + +{{ end }}