diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 9d1a43f1..55fa1328 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -49,7 +49,7 @@ {{- if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }} {{- template "_internal/google_analytics_async.html" . }} -{{- template "_internal/opengraph.html" . }} -{{- template "_internal/twitter_cards.html" . }} -{{- template "_internal/schema.html" . }} +{{- template "partials/templates/opengraph.html" . }} +{{- template "partials/templates/twitter_cards.html" . }} +{{- template "partials/templates/schema.html" . }} {{- end }} \ No newline at end of file diff --git a/layouts/partials/templates/opengraph.html b/layouts/partials/templates/opengraph.html new file mode 100644 index 00000000..834e3a12 --- /dev/null +++ b/layouts/partials/templates/opengraph.html @@ -0,0 +1,65 @@ + + + + +{{- if .Params.cover.image -}} +{{- if (ne .Params.cover.relative true) }} + +{{- else}} + +{{- end}} +{{- else }} +{{ 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 }} +{{- 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/templates/schema.html b/layouts/partials/templates/schema.html new file mode 100644 index 00000000..6c032b66 --- /dev/null +++ b/layouts/partials/templates/schema.html @@ -0,0 +1,31 @@ + + + +{{- if .IsPage }}{{ $ISO8601 := "2006-01-02T15:04:05-07:00" }}{{ if not .PublishDate.IsZero }} +{{ end }} +{{ if not .Lastmod.IsZero }}{{ end }} + +{{- if .Params.cover.image -}} +{{- if (ne .Params.cover.relative true) }} + +{{- else}} + +{{- end}} +{{- else }} +{{ 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 }} +{{- end }} + + + +{{- end }} diff --git a/layouts/partials/templates/twitter_cards.html b/layouts/partials/templates/twitter_cards.html new file mode 100644 index 00000000..de86c781 --- /dev/null +++ b/layouts/partials/templates/twitter_cards.html @@ -0,0 +1,38 @@ +{{- if .Params.cover.image -}} + +{{- if (ne $.Params.cover.relative true) }} + +{{- else }} + +{{- end}} +{{- else }} +{{- 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 }} +{{- end }} + + +{{ with .Site.Social.twitter -}} + +{{ end -}} +{{ range .Site.Authors }} +{{ with .twitter -}} + +{{ end -}} +{{ end -}} \ No newline at end of file