Merge pull request #126 from willstocks/master

Tweak OpenGraph and Twitter meta tags
This commit is contained in:
Radek Kozieł 2020-03-20 18:15:30 +01:00 committed by GitHub
commit bd1f2c75d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 15 deletions

View File

@ -98,11 +98,19 @@ paginate = 5
# it's set to `true` by default # it's set to `true` by default
# oneHeadingSize = false # oneHeadingSize = false
[params.twitter]
# set Twitter handles for Twitter cards
# see https://developer.twitter.com/en/docs/tweets/optimize-with-cards/guides/getting-started#card-and-content-attribution
# do not include @
creator = ""
site = ""
[languages] [languages]
[languages.en] [languages.en]
languageName = "English" languageName = "English"
title = "Terminal" title = "Terminal"
subtitle = "A simple, retro theme for Hugo" subtitle = "A simple, retro theme for Hugo"
owner = ""
keywords = "" keywords = ""
copyright = "" copyright = ""
menuMore = "Show more" menuMore = "Show more"

View File

@ -25,6 +25,7 @@
- https://www.rockyourcode.com **Sophia Brandt** (tax officer and hobby coder) - https://www.rockyourcode.com **Sophia Brandt** (tax officer and hobby coder)
- https://qbunt.com **Jeremy Bunting** (Software Engineer) - https://qbunt.com **Jeremy Bunting** (Software Engineer)
- https://smeik.org **Smeik** (Embedded Developer) - https://smeik.org **Smeik** (Embedded Developer)
- https://code.willstocks.co.uk **Will Stocks** (Blogger & Developer)
<!-- <!--
TEMPLATE: TEMPLATE:

View File

@ -2,6 +2,7 @@
title = "" title = ""
date = "" date = ""
author = "" author = ""
authorTwitter = "" #do not include @
cover = "" cover = ""
tags = ["", ""] tags = ["", ""]
keywords = ["", ""] keywords = ["", ""]

View File

@ -1,8 +1,8 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<meta name="description" content="{{ if .IsHome }}{{ .Site.Params.Subtitle }}{{ else }}{{ .Summary | plainify }}{{ end }}"/> <meta name="description" content="{{ if .IsHome }}{{ .Site.Params.Subtitle }}{{ else }}{{ .Summary | plainify }}{{ end }}" />
<meta name="keywords" content="{{ with .Params.Keywords }}{{ delimit . ", " }}{{ else }}{{ $.Site.Params.Keywords }}{{ end }}"/> <meta name="keywords" content="{{ with .Params.Keywords }}{{ delimit . ", " }}{{ else }}{{ $.Site.Params.Keywords }}{{ end }}" />
<meta name="robots" content="noodp"/> <meta name="robots" content="noodp" />
<link rel="canonical" href="{{ .Permalink }}" /> <link rel="canonical" href="{{ .Permalink }}" />
{{ template "_internal/google_analytics.html" . }} {{ template "_internal/google_analytics.html" . }}
@ -21,31 +21,34 @@
<!-- Icons --> <!-- Icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="{{ "img/apple-touch-icon-144-precomposed.png" | absURL }}"> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="{{ "img/apple-touch-icon-144-precomposed.png" | absURL }}">
{{ if isset $.Site.Params "favicon" }} {{ if isset $.Site.Params "favicon" }}
<link rel="shortcut icon" href="{{ $.Site.Params.favicon | absURL }}"> <link rel="shortcut icon" href="{{ $.Site.Params.favicon | absURL }}">
{{ else }} {{ else }}
<link rel="shortcut icon" href="{{ printf "img/favicon/%s.png" $.Site.Params.ThemeColor | absURL }}"> <link rel="shortcut icon" href="{{ printf "img/favicon/%s.png" $.Site.Params.ThemeColor | absURL }}">
{{ end }} {{ end }}
<!-- Twitter Card --> <!-- Twitter Card -->
<meta name="twitter:card" content="summary" /> <meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="{{ if .IsHome }}{{ $.Site.Title }} — {{ $.Site.Params.Subtitle }}{{ else }}{{ .Title }} :: {{ $.Site.Title }} — {{ $.Site.Params.Subtitle }}{{ end }}" /> {{ if (isset $.Site.Params.Twitter "site") }}
<meta name="twitter:description" content="{{ if .IsHome }}{{ $.Site.Params.tagline }}{{ else }}{{ .Summary | plainify }}{{ end }}" /> <meta name="twitter:site" content="{{ $.Site.Params.Twitter.site }}" />
<meta name="twitter:site" content="{{ $.Site.BaseURL }}" /> {{ end }}
<meta name="twitter:creator" content="{{ .Params.Author }}" /> <meta name="twitter:creator" content="{{ if .IsHome }}{{ $.Site.Params.Twitter.creator }}{{ else if isset .Params "authortwitter" }}{{ .Params.authorTwitter }}{{ else }}{{ .Params.Author }}{{ end }}" />
<meta name="twitter:image" content="{{ with .Params.Cover }}{{ . | absURL }}{{ end }}">
<!-- OG data --> <!-- OG data -->
<meta property="og:locale" content="{{ $.Site.Language.Lang }}" /> <meta property="og:locale" content="{{ $.Site.Language.Lang }}" />
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" /> <meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
<meta property="og:title" content="{{ if .IsHome }}{{ $.Site.Title }} — {{ $.Site.Params.Subtitle }}{{ else }}{{ .Title }} :: {{ $.Site.Title }} — {{ $.Site.Params.Subtitle }}{{ end }}"> <meta property="og:title" content="{{ if .IsHome }}{{ $.Site.Title }}{{ else }}{{ .Title }} :: {{ $.Site.Title }}{{ end }}">
<meta property="og:description" content="{{ if .IsHome }}{{ $.Site.Params.tagline }}{{ else }}{{ .Summary | plainify }}{{ end }}" /> <meta property="og:description" content="{{ if .IsHome }}{{ $.Site.Params.Subtitle }}{{ else }}{{ .Summary | plainify }}{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" /> <meta property="og:url" content="{{ .Permalink }}" />
<meta property="og:site_name" content="{{ .Title }}" /> <meta property="og:site_name" content="{{ .Title }}" />
<meta property="og:image" content="{{ with .Params.Cover }}{{ . | absURL }}{{ end }}"> <meta property="og:image" content="{{ if .IsHome }}{{ $.Site.Params.favicon | absURL }}{{else}}{{ .Params.Cover | absURL }}{{ end }}">
<meta property="og:image:width" content="2048"> <meta property="og:image:width" content="2048">
<meta property="og:image:height" content="1024"> <meta property="og:image:height" content="1024">
{{ range .Params.categories }}<meta property="article:section" content="{{ . }}" />{{ end }} {{ range .Params.categories }}
{{ if isset .Params "date" }}<meta property="article:published_time" content="{{ time .Date }}" />{{ end }} <meta property="article:section" content="{{ . }}" />
{{ end }}
{{ if isset .Params "date" }}
<meta property="article:published_time" content="{{ time .Date }}" />
{{ end }}
<!-- RSS --> <!-- RSS -->
{{ with .OutputFormats.Get "RSS" }} {{ with .OutputFormats.Get "RSS" }}