Browse Source

[#11] Add open graph tags

Initial pass at open graph tags for sharing content on social media. Only
catering for minimal set of tags and use cases for now.
main
Tony Wolski 8 months ago
parent
commit
11c89a7b8a
Signed by: awolski GPG Key ID: D8F316C14B590AE1
  1. 3
      config.toml
  2. 0
      content/blog/first-post/index.md
  3. 37
      themes/yvant/layouts/partials/head.html

3
config.toml

@ -4,6 +4,9 @@ defaultContentLanguage = 'en'
title = 'Yvant'
theme = 'yvant'
[params]
logo = 'yvant.png'
[languages]
[languages.en]
languageCode = 'en'

0
content/blog/first-post.md → content/blog/first-post/index.md

37
themes/yvant/layouts/partials/head.html

@ -2,9 +2,42 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta http-equiv="Permissions-Policy" content="interest-cohort=()">
<meta name="description" content="{{ default (truncate 160 .Summary) .Description }}"/>
{{ $title := print .Title " | " .Site.Title }}
{{ if .IsHome }}{{ $title = print .Site.Title " | " .Title }}{{ end }}
{{ $description := default (truncate 160 .Summary) .Params.description }}
{{ $image := print .Site.BaseURL .Site.Params.logo }}
{{ if .IsHome }}
{{ $title = print .Site.Title " | " .Title }}
{{ end }}
{{ if .Params.image }}
{{ $image = print .Permalink .Params.image }}
{{ end }}
<!-- Start of Open Graph -->
<meta property="og:title" content="{{ $title }}">
<meta property="og:description" content="{{ $description }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:site_name" content="{{ .Site.Title }}">
{{ if .IsPage }}
<meta property="og:type" content="article">
{{ else }}
<meta property="og:type" content="website">
{{ end }}
<meta property="og:image" content="{{ $image }}">
{{ range .Params.tags }}
<meta property="og:tags" content="{{ . }}">
{{ end }}
<!-- End of Open Graph -->
<!-- Start of Twitter -->
<meta property="twitter:card" content="summary">
<meta property="twitter:description" content="{{ $description }}">
<meta property="twitter:title" content="{{ $title }}">
{{ if .Params.image }}
<meta property="twitter:image" content="{{ $image }}">
{{ end }}
<!-- End of Twitter -->
<meta name="description" content="{{ $description }}"/>
<title>{{ $title }}</title>
<link rel="icon" href="/Y.ico"/>
<link rel="stylesheet" href="/css/pico.min.css"/>

Loading…
Cancel
Save