aboutsummaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/seo_tags.html6
-rw-r--r--layouts/partials/social_card.html17
2 files changed, 8 insertions, 15 deletions
diff --git a/layouts/partials/seo_tags.html b/layouts/partials/seo_tags.html
index 84ab39e..81e498f 100644
--- a/layouts/partials/seo_tags.html
+++ b/layouts/partials/seo_tags.html
@@ -3,7 +3,11 @@
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
<meta name="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 }}" />
-{{ if (default false .Site.Params.generateSocialCard) }}
+<!-- Only generate social card if: -->
+<!-- - generateSocialCard = true -->
+<!-- - there aren't images set in frontmatter -->
+<!-- - page is of .Kind "page" -->
+{{ if and (and (default false .Site.Params.generateSocialCard) (not (isset .Params "images"))) (eq .Kind "page") }}
{{ partial "social_card.html" . }}
{{ else }}
<!-- Open Graph / Facebook -->
diff --git a/layouts/partials/social_card.html b/layouts/partials/social_card.html
index 77bc251..8bf397f 100644
--- a/layouts/partials/social_card.html
+++ b/layouts/partials/social_card.html
@@ -13,7 +13,8 @@
)) }}
{{ $date := .Date.Format (default "2006-01-02" .Site.Params.dateFormat) }}
-{{ $byline := (printf "%s | %s" ($.Param "author") $date) }}
+{{ $author := (default $.Site.Author.name ($.Param "author") ) }}
+{{ $byline := (printf "%s | %s" $author $date) }}
{{ $fg = $fg.Filter (images.Text $byline (dict
"font" $font
@@ -34,11 +35,7 @@
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" />
-{{- with .Params.images -}}
-{{- range first 6 . }}<meta property="og:image" content="{{ . | absURL }}" />{{ end -}}
-{{- else -}}
<meta property="og:image" content="{{ $card.Permalink | absURL }}"/>
-{{- end -}}
{{- if .IsPage }}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
@@ -71,13 +68,9 @@
<!-- Twitter -->
<!-- Source: 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 -}}
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="{{ $card.Permalink | absURL }}"/>
-{{- 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 -}}
@@ -95,11 +88,7 @@
{{ 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 -}}
<meta itemprop="image" content="{{ $card.Permalink | absURL }}"/>
-{{- 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 }}" />