From 7b111417706693ed18038fb3ff243836fd154a58 Mon Sep 17 00:00:00 2001 From: Tobias Manske Date: Fri, 26 Feb 2021 15:26:50 +0100 Subject: [PATCH] Twitter Card optimization --- config.toml | 1 + layouts/partials/head.html | 85 +++++++++++++++++++ layouts/partials/templates/twitter_cards.html | 12 +++ 3 files changed, 98 insertions(+) create mode 100644 layouts/partials/head.html create mode 100644 layouts/partials/templates/twitter_cards.html diff --git a/config.toml b/config.toml index 5f11bda..f6e9fb4 100644 --- a/config.toml +++ b/config.toml @@ -15,6 +15,7 @@ enableRobotsTXT = true ShowBreadCrumbs = true ShowShareButtons = true author = "Tobias Manske" + twitter = "@rad4day" description = "Blog about learning and technology by a KIT University Student" [params.homeInfoParams] title = "Welcome!" diff --git a/layouts/partials/head.html b/layouts/partials/head.html new file mode 100644 index 0000000..d63141d --- /dev/null +++ b/layouts/partials/head.html @@ -0,0 +1,85 @@ + + + +{{- if hugo.IsProduction | or (eq .Site.Params.env "production") }} + +{{- else }} + +{{- end -}} + +{{ if .IsHome }}{{else}}{{ if .Title }}{{ .Title }} | {{ end }}{{end}}{{ .Site.Title }} + + + + + +{{- if .Site.Params.analytics.google.SiteVerificationTag }} + +{{- end}} +{{- if .Site.Params.analytics.yandex.SiteVerificationTag }} + +{{- end}} +{{- if .Site.Params.analytics.bing.SiteVerificationTag }} + +{{- end}} + +{{- $common := (resources.Match "css/*.css") | resources.Concat "assets/css/common.css" }} +{{- $extended := (resources.Match "css/extended/*.css") | resources.Concat "assets/css/extended.css" }} +{{- /* bundle all required css */}} +{{- /* Add extended css after theme style */ -}} +{{- $stylesheet := (slice $common $extended) | resources.Concat "assets/css/stylesheet.css" | minify }} + +{{- if not .Site.Params.assets.disableFingerprinting }} +{{- $stylesheet := $stylesheet | fingerprint -}} + +{{- else}} + +{{- end}} + +{{- if (eq .Layout `search`) -}} + +{{- $fastsearch := resources.Get "js/fastsearch.js" | resources.ExecuteAsTemplate "js/fastsearch.js" .Site.Params.fuseOpts }} +{{- $fusejs := resources.Get "js/fuse.js" }} +{{- if not .Site.Params.assets.disableFingerprinting }} +{{- $search := (slice $fusejs $fastsearch ) | resources.Concat "assets/js/search.js" | minify | fingerprint }} + +{{- else}} +{{ $search := (slice $fusejs $fastsearch ) | resources.Concat "assets/js/search.js" | minify }} + +{{- end}} +{{- end -}} + + + + + + + + + + +{{- hugo.Generator }} + +{{ range .AlternativeOutputFormats -}} + {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} +{{ end -}} +{{- range .AllTranslations -}} + +{{ end }} +{{- partial "extend_head.html" . -}} + +{{- if hugo.IsProduction | or (eq .Site.Params.env "production") }} +{{- template "_internal/google_analytics_async.html" . }} +{{- template "_internal/google_news.html" . }} +{{- template "partials/templates/opengraph.html" . }} +{{- template "partials/templates/twitter_cards.html" . }} +{{- template "partials/templates/schema_json.html" . }} +{{- end }} diff --git a/layouts/partials/templates/twitter_cards.html b/layouts/partials/templates/twitter_cards.html new file mode 100644 index 0000000..6c1af68 --- /dev/null +++ b/layouts/partials/templates/twitter_cards.html @@ -0,0 +1,12 @@ + + + + + +{{- with .Params.image }} + + +{{- else }} + + +{{- end }}