diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-05-01 11:08:16 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-05-01 11:08:16 +0200 |
| commit | 4c70f6a3a6d780c2933585dbfb8fb72a4bc75c12 (patch) | |
| tree | e85242b243bd81b2e1552f486223da41ececb8fa /layouts | |
| parent | 80c4189a9eaa6e5a9d643199bd4f80f541b9d5aa (diff) | |
| download | gohugo-theme-ed-4c70f6a3a6d780c2933585dbfb8fb72a4bc75c12.tar.gz | |
Rework opengraph support
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/partials/head.html | 16 | ||||
| -rw-r--r-- | layouts/partials/templates/opengraph.html | 28 |
2 files changed, 30 insertions, 14 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html index e7c14bd..5c76d9f 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -25,20 +25,8 @@ {{- if .Params.rights }}<meta property="dc:rights" content="{{ .Params.rights }}">{{ end }} <meta property="dc:source" content="{{ if .Params.source }}{{ .Params.source }}{{ else }}{{ .Site.Title }}{{ end }}"> - <!-- Open Graph metadata --> - <meta property="og:title" content="{{ .Title }}"> - <meta property="og:url" content="{{ .Permalink }}"> - {{/* TODO: Check for reatured image */ -}} - <meta property="og:image" content="{{ "img/open-graph-logo.png" | absURL }}"> - <meta property="og:image:width" content="200"> - <meta property="og:image:height" content="200"> - {{- /* TODO: add fb:admins and fb:app_id */ -}} - <!-- meta property="fb:admins" content="" --> - <!-- meta property="fb:app_id" content="" --> - - {{- /* TODO: add ability to render 'article' type */ -}} - <meta property="og:description" content="{{ .Site.Params.Description }}"> - <meta property="og:type" content="website"> + {{- /* Misc */}} + {{template "partials/templates/opengraph.html" . }} {{ partial "styles.html" . -}} {{ partial "scripts.html" . -}} diff --git a/layouts/partials/templates/opengraph.html b/layouts/partials/templates/opengraph.html new file mode 100644 index 0000000..71e040e --- /dev/null +++ b/layouts/partials/templates/opengraph.html @@ -0,0 +1,28 @@ +<!-- Open Graph metadata --> + <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 .Params.cover.image -}} + {{- if (ne .Params.cover.relative true) }} + <meta property="og:image" content="{{ .Params.cover.image | absURL }}" /> + {{- else }} + <meta property="og:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" /> + {{- end }} + + {{- if .Params.cover.width -}} + <meta property="og:image:width" content="{{ .Params.cover.width }}"> + {{- end }} + + {{- if .Params.cover.height -}} + <meta property="og:image:height" content="{{ .Params.cover.height }}"> + {{- end }} +{{- else }} + <meta property="og:image" content="{{ "img/open-graph-logo.png" | absURL }}"> + <meta property="og:image:width" content="200"> + <meta property="og:image:height" content="200"> +{{- end }} + +{{- /* TODO: add fb:admins and fb:app_id */ -}} +<!-- meta property="fb:admins" content="" --> +<!-- meta property="fb:app_id" content="" --> |
