From be4bbc3bca483cdc22e0342b4c83ab21a64446dd Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Mon, 14 Apr 2025 07:48:59 +0300 Subject: [PATCH] layouts/partials: use internal Hugo partials As of Hugo v0.146.0 the template system was overhauled and it seems we need to use different syntax here. The reason for overriding the Hugo internal templates in the past (post images) is no longer pre- sent, so I can revert to the internal ones, but confusingly, we do not refer to them with "_internal" now. See: https://github.com/gohugoio/hugo/pull/13541 --- layouts/partials/head-meta.html | 4 +- layouts/partials/opengraph.html | 73 ----------------------------- layouts/partials/twitter_cards.html | 42 ----------------- 3 files changed, 2 insertions(+), 117 deletions(-) delete mode 100644 layouts/partials/opengraph.html delete mode 100644 layouts/partials/twitter_cards.html diff --git a/layouts/partials/head-meta.html b/layouts/partials/head-meta.html index 37d500f..cc74ff6 100644 --- a/layouts/partials/head-meta.html +++ b/layouts/partials/head-meta.html @@ -1,8 +1,8 @@ -{{ partial "opengraph.html" . }} -{{ partial "twitter_cards.html" . }} +{{- partial "opengraph.html" . }} +{{- partial "twitter_cards.html" . }} {{- with .Site.Params.google_verify_meta -}} diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html deleted file mode 100644 index 7b7ed98..0000000 --- a/layouts/partials/opengraph.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - -{{ with $.Params.images }}{{ range first 6 . -}} -{{/* try to get the image from the page bundle */}} -{{- with $.Page.Resources.GetMatch (printf "*%s*" .) -}} - -{{/* otherwise, get the image from /static */}} -{{- else -}} - -{{- end }} -{{ 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 }} - -{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} -{{- if .IsPage }} -{{- if not .PublishDate.IsZero }} -{{ else if not .Date.IsZero }} -{{ end }} -{{- if not .Lastmod.IsZero }}{{ end }} -{{- else }} -{{- if not .Date.IsZero }} -{{- end }} -{{- end }}{{/* .IsPage */}} - -{{- with .Params.audio }}{{ end }} -{{- with .Params.locale }}{{ end }} -{{- with .Site.Params.title }}{{ end }} -{{- with .Params.videos }} -{{- range . }} - -{{ end }}{{ 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 }} - {{- range $page := first 6 $series.Pages }} - {{- if ne $page.Permalink $permalink }}{{ end }} - {{- end }} -{{ end }}{{ end }} - -{{- if .IsPage }} -{{- range .Site.Authors }}{{ with .Social.facebook }} -{{ end }}{{ with .Site.Social.facebook }} -{{ end }} - -{{- with .Params.tags }}{{ range first 6 . }} -{{ end }}{{ end }} -{{- end }}{{ end }} - -{{- /* Facebook Page Admin ID for Domain Insights */}} -{{- with .Site.Social.facebook_admin }}{{ end }} - - diff --git a/layouts/partials/twitter_cards.html b/layouts/partials/twitter_cards.html deleted file mode 100644 index 0f90bd1..0000000 --- a/layouts/partials/twitter_cards.html +++ /dev/null @@ -1,42 +0,0 @@ - -{{- with $.Params.images -}} - -{{/* try to get the image from the page bundle */}} -{{- with $.Page.Resources.GetMatch (printf "*%s*" .) -}} - -{{- else -}} - -{{- 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 -}} - - -{{ else -}} - -{{- end -}} -{{- end -}} -{{- end }} - - -{{ with .Site.Social.twitter -}} - -{{ end -}} -{{ range .Site.Authors }} -{{ with .twitter -}} - -{{ end -}} -{{ end -}}