From 819cbc3ae8408cd1bf195149f9290542d90cb5e4 Mon Sep 17 00:00:00 2001 From: Henk Verlinde Date: Fri, 25 Jun 2021 16:04:42 +0200 Subject: [PATCH] feat: update meta tags --- config/_default/params.toml | 31 ++- layouts/_default/section.sitemap.xml | 12 +- layouts/index.redirects | 2 +- layouts/partials/head/favicons.html | 8 +- layouts/partials/head/opengraph.html | 102 +++----- layouts/partials/head/resource-hints.html | 8 +- layouts/partials/head/seo.html | 28 +-- layouts/partials/head/structured-data.html | 275 ++++++++++++++------- layouts/partials/head/stylesheet.html | 4 +- layouts/partials/head/twitter_cards.html | 27 +- layouts/rss.xml | 8 +- layouts/sitemap.xml | 6 +- static/{doks.svg => logo-doks.svg} | 0 13 files changed, 294 insertions(+), 217 deletions(-) rename static/{doks.svg => logo-doks.svg} (100%) diff --git a/config/_default/params.toml b/config/_default/params.toml index f97b6d0..9601055 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -6,20 +6,34 @@ titleSeparator = "-" titleAddition = "Modern Documentation Theme" description = "Doks is a Hugo theme helping you build modern documentation websites that are secure, fast, and SEO-ready — by default." -## Open Graph + Twitter Cards +## Open Graph images = ["doks.png"] -twitterSite = "henkverlinde" -twitterCreator = "henkverlinde" -facebookAuthor = "verlinde.henk" -facebookPublisher = "verlinde.henk" ogLocale = "en_US" +domainTLD = "doks.netlify.app" +titleHome = "Doks Theme" + +## Twitter Cards +twitterSite = "@getdoks" +twitterCreator = "@henkverlinde" ## JSON-LD +# schemaType = "Person" schemaType = "Organization" +schemaName = "Doks" +schemaAuthor = "Henk Verlinde" +schemaAuthorTwitter = "https://twitter.com/henkverlinde" +schemaAuthorLinkedIn = "https://www.linkedin.com/in/henkverlinde/" +schemaAuthorGitHub = "https://github.com/h-enk" +schemaLocale = "en-US" schemaLogo = "logo-doks.png" -schemaTwitter = "https://twitter.com/henkverlinde" -schemaLinkedIn = "https://www.linkedin.com/in/henkverlinde/" -schemaGitHub = "https://github.com/h-enk" +schemaLogoWidth = 512 +schemaLogoHeight = 512 +schemaImage = "doks.png" +schemaImageWidth = 1280 +schemaImageHeight = 640 +schemaTwitter = "https://twitter.com/getdoks" +schemaLinkedIn = "" +schemaGitHub = "https://github.com/h-enk/doks" schemaSection = "blog" ## Sitelinks Search Box @@ -37,6 +51,7 @@ lqipWidth = "20x" # Footer footer = "Powered by Netlify, Hugo, and Doks" +copyRight = "Copyright (c) 2020-2021 Henk Verlinde" # Alert alert = false diff --git a/layouts/_default/section.sitemap.xml b/layouts/_default/section.sitemap.xml index 9d047b4..701951d 100644 --- a/layouts/_default/section.sitemap.xml +++ b/layouts/_default/section.sitemap.xml @@ -4,19 +4,19 @@ {{ range $i, $e := .Data.Pages -}} {{ if ne .Params.sitemap_exclude true }} - {{ .RelPermalink }}{{ if not .Lastmod.IsZero }} + {{ .Permalink }}{{ if not .Lastmod.IsZero }} {{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}{{ end }}{{ with .Sitemap.ChangeFreq }} {{ . }}{{ end }}{{ if ge .Sitemap.Priority 0.0 }} {{ .Sitemap.Priority }}{{ end }}{{ if .IsTranslated }}{{ range .Translations }} {{ end }} {{ end }} {{ end -}} @@ -25,19 +25,19 @@ {{ range $i, $e := .Data.Pages -}} {{ if ne .Params.sitemap_exclude true -}} - {{ .RelPermalink }}{{ if not .Lastmod.IsZero }} + {{ .Permalink }}{{ if not .Lastmod.IsZero }} {{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}{{ end }}{{ with .Sitemap.ChangeFreq }} {{ . }}{{ end }}{{ if ge .Sitemap.Priority 0.0 }} {{ .Sitemap.Priority }}{{ end }}{{ if .IsTranslated }}{{ range .Translations }} {{ end }} {{ end }} {{ end -}} diff --git a/layouts/index.redirects b/layouts/index.redirects index 59a844c..4323285 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,6 +1,6 @@ # redirects for Netlify - https://www.netlify.com/docs/redirects/ {{- range $p := .Site.Pages -}} {{- range .Aliases }} -{{ . }} {{ $p.RelRelPermalink -}} +{{ . }} {{ $p.RelPermalink -}} {{- end }} {{- end -}} \ No newline at end of file diff --git a/layouts/partials/head/favicons.html b/layouts/partials/head/favicons.html index 48d2a0e..c034df1 100644 --- a/layouts/partials/head/favicons.html +++ b/layouts/partials/head/favicons.html @@ -1,5 +1,5 @@ - - - - + + + + diff --git a/layouts/partials/head/opengraph.html b/layouts/partials/head/opengraph.html index e375302..6127e82 100644 --- a/layouts/partials/head/opengraph.html +++ b/layouts/partials/head/opengraph.html @@ -1,30 +1,15 @@ + + - {{ if $.Scratch.Get "paginator" -}} {{ $paginator := .Paginate (where .Site.RegularPages.ByDate.Reverse "Section" "blog" ) -}} - + {{ else -}} - + {{ end -}} - -{{ with $.Params.images -}} - {{ range first 6 . -}} - - {{ end -}} -{{ else -}} - {{ $images := $.Resources.ByType "image" -}} - {{ $featured := $images.GetMatch "*feature*" -}} - {{ if not $featured -}} - {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }} - {{ end -}} - {{ with $featured -}} - - {{ else -}} - {{ with $.Site.Params.images -}} - - {{ end -}} - {{ end -}} +{{ with .Site.Params.title -}} + {{ end -}} {{ $iso8601 := "2006-01-02T15:04:05-07:00" -}} @@ -43,51 +28,42 @@ {{ end -}} {{ end -}} +{{ if eq .Kind "home" -}} + {{ .Scratch.Set "title" .Site.Params.titleHome -}} +{{ else -}} + {{ .Scratch.Set "title" .Title -}} +{{ end -}} + +{{ with $.Params.images -}} + {{ range first 6 . -}} + + {{ end -}} +{{ else -}} + {{ $images := $.Resources.ByType "image" -}} + {{ $featured := $images.GetMatch "*feature*" -}} + {{ if not $featured -}} + {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }} + {{ end -}} + {{ with $featured -}} + + {{ else -}} + {{ with $.Site.Params.images -}} + + + {{ end -}} + {{ end -}} +{{ end -}} + +{{ with $.Site.Params.images -}} + {{ $.Scratch.Set "primaryImage" (index . 0 | absURL) -}} +{{ end -}} + {{ with .Params.audio -}} - -{{ end -}} -{{ with .Params.locale -}} - -{{ end -}} -{{ with .Site.Params.title -}} - + {{ end -}} + {{ with .Params.videos -}} {{ range . -}} - + {{ end -}} {{ end -}} - -{{ $RelPermalink := .RelPermalink -}} -{{ $siteSeries := .Site.Taxonomies.series -}} -{{ with .Params.series -}} - {{ range $name := . -}} - {{ $series := index $siteSeries $name -}} - {{ range $page := first 6 $series.Pages -}} - {{ if ne $page.RelPermalink $RelPermalink -}} - - {{ end -}} - {{ end -}} - {{ end -}} -{{ end -}} - -{{ if .IsPage -}} - {{ range .Site.Authors -}} - {{ with .Social.facebook -}} - - {{ end -}} - {{ with .Site.Social.facebook -}} - - {{ end -}} - - {{ with .Params.tags -}} - {{ range first 6 . -}} - - {{ end -}} - {{ end -}} - {{ end -}} -{{ end -}} - -{{ with .Site.Social.facebook_admin -}} - -{{ end -}} \ No newline at end of file diff --git a/layouts/partials/head/resource-hints.html b/layouts/partials/head/resource-hints.html index 754936d..3baa711 100644 --- a/layouts/partials/head/resource-hints.html +++ b/layouts/partials/head/resource-hints.html @@ -1,6 +1,6 @@ - - + + {{ if .Site.Params.options.kaTex -}} - - + + {{ end -}} \ No newline at end of file diff --git a/layouts/partials/head/seo.html b/layouts/partials/head/seo.html index fe21bb1..29aaef3 100644 --- a/layouts/partials/head/seo.html +++ b/layouts/partials/head/seo.html @@ -2,11 +2,11 @@ {{ else -}} {{ with .Params.robots -}} - + {{ else -}} - - - + + + {{ end -}} {{ end -}} @@ -23,28 +23,22 @@ {{ end -}} {{ if $.Scratch.Get "paginator" }} - + {{ if .Paginator.HasPrev -}} - + {{ end -}} {{ if .Paginator.HasNext -}} - + {{ end -}} -{{ else -}} - +{{ else -}} + {{ end -}} -{{ partial "head/twitter_cards.html" . }} - - - {{ partial "head/opengraph.html" . }} - - - +{{ partial "head/twitter_cards.html" . }} {{ range .AlternativeOutputFormats -}} - + {{ end -}} {{ partial "head/structured-data.html" . }} diff --git a/layouts/partials/head/structured-data.html b/layouts/partials/head/structured-data.html index 2f38fae..1f153a3 100644 --- a/layouts/partials/head/structured-data.html +++ b/layouts/partials/head/structured-data.html @@ -1,89 +1,10 @@ -{{ if .IsHome -}} - {{ if eq .Site.Params.schemaType "Organization" -}} - - {{ end -}} - {{ if eq .Site.Params.schemaType "Person" -}} - - {{ end -}} - {{ if .Site.Params.siteLinksSearchBox -}} - - {{ end -}} -{{ end -}} -{{ if .IsPage -}} - {{ if eq .Section .Site.Params.schemaSection -}} - - {{ end -}} -{{ end -}} +{{ $baseURL := "/" | absURL -}} {{ $dot := . -}} {{ $dot.Scratch.Set "path" "" -}} {{ $dot.Scratch.Set "breadcrumb" slice -}} -{{ $url := replace .RelPermalink ( printf "%s" .Site.BaseURL) "" -}} +{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" -}} {{ $.Scratch.Add "path" .Site.BaseURL -}} {{ $.Scratch.Add "breadcrumb" (slice (dict "url" .Site.BaseURL "name" "home" "position" 1 )) -}} @@ -97,13 +18,193 @@ \ No newline at end of file diff --git a/layouts/partials/head/stylesheet.html b/layouts/partials/head/stylesheet.html index 529e8f4..e5f9cc5 100644 --- a/layouts/partials/head/stylesheet.html +++ b/layouts/partials/head/stylesheet.html @@ -1,11 +1,11 @@ {{ if eq (hugo.Environment) "development" -}} {{ $options := (dict "targetPath" "main.css" "enableSourceMap" true "includePaths" (slice "node_modules")) -}} {{ $css := resources.Get "scss/app.scss" | toCSS $options -}} - + {{ else -}} {{ $options := (dict "targetPath" "main.css" "outputStyle" "compressed" "includePaths" (slice "node_modules")) -}} {{ $css := resources.Get "scss/app.scss" | toCSS $options | postCSS (dict "config" "config/postcss.config.js") -}} {{ $secureCSS := $css | resources.Fingerprint "sha512" -}} - + {{ end -}} \ No newline at end of file diff --git a/layouts/partials/head/twitter_cards.html b/layouts/partials/head/twitter_cards.html index 8086253..fdf581c 100644 --- a/layouts/partials/head/twitter_cards.html +++ b/layouts/partials/head/twitter_cards.html @@ -1,6 +1,10 @@ + + + + + {{ with $.Params.images -}} - - + {{ else -}} {{ $images := $.Resources.ByType "image" -}} {{ $featured := $images.GetMatch "*feature*" -}} @@ -8,26 +12,13 @@ {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" -}} {{ end -}} {{ with $featured -}} - - + {{ else -}} {{ with $.Site.Params.images -}} - - + {{ else -}} {{ end -}} {{ end -}} {{ end -}} - - - -{{ with .Site.Social.twitter -}} - -{{ end -}} - -{{ range .Site.Authors -}} - {{ with .twitter -}} - - {{ end -}} -{{ end -}} \ No newline at end of file + \ No newline at end of file diff --git a/layouts/rss.xml b/layouts/rss.xml index 14f92a4..72ac564 100644 --- a/layouts/rss.xml +++ b/layouts/rss.xml @@ -2,7 +2,7 @@ {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} - {{ .RelPermalink }} + {{ .Permalink }} Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }} Hugo -- gohugo.io{{ with .Site.LanguageCode }} {{.}}{{end}}{{ with .Site.Author.email }} @@ -11,15 +11,15 @@ {{.}}{{end}}{{ if not .Date.IsZero }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} {{ with .OutputFormats.Get "RSS" }} - {{ printf "" .RelPermalink .MediaType | safeHTML }} + {{ printf "" .Permalink .MediaType | safeHTML }} {{ end }} {{ range .Pages }}{{ if ne .Params.feed_exclude true }} {{ .Title }} - {{ .RelPermalink }} + {{ .Permalink }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} - {{ .RelPermalink }} + {{ .Permalink }} {{ .Summary | html }} {{ end }}{{ end }} diff --git a/layouts/sitemap.xml b/layouts/sitemap.xml index e2909ec..a3fcf7a 100644 --- a/layouts/sitemap.xml +++ b/layouts/sitemap.xml @@ -3,19 +3,19 @@ xmlns:xhtml="http://www.w3.org/1999/xhtml"> {{ range .Data.Pages }}{{ if ne .Params.sitemap_exclude true }} - {{ .RelPermalink }}{{ if not .Lastmod.IsZero }} + {{ .Permalink }}{{ if not .Lastmod.IsZero }} {{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}{{ end }}{{ with .Sitemap.ChangeFreq }} {{ . }}{{ end }}{{ if ge .Sitemap.Priority 0.0 }} {{ .Sitemap.Priority }}{{ end }}{{ if .IsTranslated }}{{ range .Translations }} {{ end }} {{ end }} {{ end }}{{ end }} diff --git a/static/doks.svg b/static/logo-doks.svg similarity index 100% rename from static/doks.svg rename to static/logo-doks.svg