mirror of
https://github.com/alanorth/hugo-theme-bootstrap4-blog.git
synced 2024-12-19 17:12:18 +01:00
Alan Orth
731af8c564
Uses basic data like title, description, author, and date that we are using with existing vanilla meta tags, but extends them to OG and Twitter Card tags. See [0] and [1]. For the Twitter summary cards specifically, you can optionally add attribution for your username by adding something like this to your configuration: [params.social] twitter_username = "@mralanorth" ... and for posts with images, you can specify an "image" in the post's front matter like so: image = "/2016/09/IMG_20160916_174409.jpg" And then the theme will opt to use Twitter's "large" summary card. [0] http://ogp.me/ [1] https://dev.twitter.com/cards/getting-started
37 lines
1.6 KiB
HTML
37 lines
1.6 KiB
HTML
{{ $title := .Title | default .Site.Title }}
|
|
{{ $description := .Params.description | default .Site.Params.description }}
|
|
{{ $author := .Params.author | default .Site.Params.author }}
|
|
|
|
<meta name="description" content="{{ $description }}">
|
|
<meta name="author" content="{{ $author }}">
|
|
|
|
{{ "<!-- OpenGraph Metadata: http://ogp.me/ -->" | safeHTML }}
|
|
<meta property="og:title" content="{{ $title }}">
|
|
<meta property="og:description" content="{{ $description }}">
|
|
|
|
{{ if eq .Section "post" }}
|
|
<meta property="og:type" content="article">
|
|
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
|
|
<meta property="article:author" content="{{ $author }}">
|
|
{{ if .Params.image }}
|
|
<meta property="og:image" content="{{ .Params.image | absURL }}">
|
|
{{ end }}
|
|
{{ else }}
|
|
<meta property="og:type" content="blog">
|
|
{{ end }}
|
|
|
|
<meta property="og:url" content="{{ .Permalink }}">
|
|
|
|
{{ "<!-- Metadata for Twitter: https://dev.twitter.com/cards/markup -->" | safeHTML }}
|
|
{{ if and (eq .Section "post") (.Params.image) }}
|
|
<meta property="twitter:card" content="summary_large_image">
|
|
<meta property="twitter:image" content="{{ .Params.image | absURL }}">
|
|
{{ else }}
|
|
<meta property="twitter:card" content="summary">
|
|
{{ end }}
|
|
{{ if .Site.Params.social.twitter_username}}<meta property="twitter:creator" content="{{ .Site.Params.social.twitter_username }}">{{ end }}
|
|
<meta property="twitter:title" content="{{ $title }}">
|
|
<meta property="twitter:description" content="{{ $description }}">
|
|
|
|
{{ .Hugo.Generator }}
|