aboutsummaryrefslogtreecommitdiffstats
path: root/layouts/partials
diff options
context:
space:
mode:
authorOscar Najera <hi@oscarnajera.com>2023-09-07 03:58:40 +0200
committerOscar Najera <hi@oscarnajera.com>2023-09-07 03:58:40 +0200
commit750727091bdc7723c5e780bb9872c9b538314c3a (patch)
tree23c4592c38d1bf5b5a05e884a2e5dda6d178ef48 /layouts/partials
parent5e20b8d99cd4591cc9d066370139d210d673864c (diff)
downloadhugo-minimalist-theme-750727091bdc7723c5e780bb9872c9b538314c3a.tar.gz
hugo-minimalist-theme-750727091bdc7723c5e780bb9872c9b538314c3a.tar.bz2
hugo-minimalist-theme-750727091bdc7723c5e780bb9872c9b538314c3a.zip
Structured data instead of internal templates of social media
Diffstat (limited to 'layouts/partials')
-rw-r--r--layouts/partials/head.html11
-rw-r--r--layouts/partials/post.html2
-rw-r--r--layouts/partials/structured-data.html51
3 files changed, 56 insertions, 8 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index bd6d93f..3a569e7 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -1,19 +1,16 @@
<head>
<meta charset="utf-8">
- <link rel="icon" href="/images/favicon.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
-{{ template "_internal/twitter_cards.html" . }}
-{{ template "_internal/opengraph.html" . }}
+ {{ partial "structured-data.html" . }}
{{ with resources.Get "scss/style.scss" | resources.ToCSS (dict "includePaths" (slice "node_modules") "targetPath" "css/style.css") | resources.Minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous" type="text/css" media="screen" />
{{ end }}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" integrity="sha512-9usAa10IRO0HhonpyAIVpjrylPvoDwiPUiKdWk5t3PyolY1cOd4DSE0Ga+ri4AuTroPR5aQvXU9xC6qOPnzFeg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
- {{ $title := print .Site.Title " | " .Title }}
- {{ if .IsHome }}{{ $title = .Site.Title }}{{ end }}
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
- <title>{{ $title }}</title>
+ <link rel="icon" href="/images/favicon.png">
{{ range .AlternativeOutputFormats -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
+
+<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
</head>
diff --git a/layouts/partials/post.html b/layouts/partials/post.html
index 53aa735..c1e66d5 100644
--- a/layouts/partials/post.html
+++ b/layouts/partials/post.html
@@ -2,7 +2,7 @@
<a class="db no-underline dim" href= "{{ .RelPermalink }}">
<h3 class="f3 baskerville mt0 lh-title near-black">{{.Title }}</h3>
<div class="cf">
- {{ with resources.Get (index .Params.images 0) | default (resources.Get .Params.image) }}
+ {{ with resources.Get (index .Params.images 0) }}
{{ $image := .Resize (default "320x" .Params.thumbnail_size) }}
<div class="fl-ns mb4 mb0-ns pr3-ns">
<img src="{{ $image.RelPermalink }}" class="db center">
diff --git a/layouts/partials/structured-data.html b/layouts/partials/structured-data.html
new file mode 100644
index 0000000..8d4e917
--- /dev/null
+++ b/layouts/partials/structured-data.html
@@ -0,0 +1,51 @@
+{{ $title := print .Site.Title " | " .Title }}
+{{ if .IsHome }}{{ $title = .Site.Title }}{{ end }}
+<title>{{ $title }}</title>
+
+{{ with resources.Get (index .Params.images 0) }}
+{{ $image := .Fill (default "400x400" $.Params.image_size) }}
+<meta name="twitter:card" content="summary_large_image"/>
+<meta name="twitter:image" content="{{ $image.Permalink }}"/>
+<meta property="og:image" content="{{ $image.Permalink }}"/>
+{{ else }}
+<meta name="twitter:card" content="summary"/>
+{{ end }}
+<meta name="twitter:title" content="{{ .Title }}"/>
+<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
+{{ with .Site.Social.twitter -}}
+<meta name="twitter:site" content="@{{ . }}"/>
+{{ end -}}
+
+<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:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
+<meta property="og:url" content="{{ .Permalink }}" />
+
+{{- if .IsPage }}
+{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
+<meta property="article:section" content="{{ .Section }}" />
+{{ with .PublishDate }}<meta property="article:published_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
+{{ with .Lastmod }}<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
+{{- end -}}
+
+{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
+{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
+{{- with .Site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
+{{- with .Params.videos }}{{- range . }}
+<meta property="og:video" content="{{ . | absURL }}" />
+{{ end }}{{ end }}
+
+{{- /* If it is part of a series, link to related articles */}}
+{{- $permalink := .Permalink }}
+{{- $siteSeries := .Site.Taxonomies.series }}
+{{- if $siteSeries }}
+{{ with .Params.series }}{{- range $name := . }}
+ {{- $series := index $siteSeries ($name | urlize) }}
+ {{- range $page := first 6 $series.Pages }}
+ {{- if ne $page.Permalink $permalink }}<meta property="og:see_also" content="{{ $page.Permalink }}" />{{ end }}
+ {{- end }}
+{{ end }}{{ end }}
+{{- end }}
+
+{{- /* Facebook Page Admin ID for Domain Insights */}}
+{{- with .Site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}