From 99d814c09d76be0574f78670c7a7080fad95a8f1 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 5 Jun 2022 22:11:41 +0200 Subject: Rework site keywords --- layouts/_default/list.atom.xml | 17 +++++++++++++---- layouts/partials/head.html | 10 ++++------ layouts/partials/keywords.html | 16 ++++++++++++---- 3 files changed, 29 insertions(+), 14 deletions(-) (limited to 'layouts') diff --git a/layouts/_default/list.atom.xml b/layouts/_default/list.atom.xml index 5da5f25..eabd899 100644 --- a/layouts/_default/list.atom.xml +++ b/layouts/_default/list.atom.xml @@ -37,11 +37,20 @@ urn:uuid:{{ substr $uuid 0 8 }}-{{ substr $uuid 8 4 }}-5{{ substr $uuid 13 3 }}-{{ substr $uuid 16 1 }}9{{ substr $uuid 17 2 }}-{{ substr $uuid 21 12 }}{{- range $pages }} {{- $url := .Permalink | absURL }}{{ $uuid := sha1 (.Permalink | absURL) }}{{ $page := . }} - {{ range (.GetTerms "tags") }} - {{ end }} + {{ $section := .Section }} + + {{ range (.GetTerms "tags") }} + {{ if not (eq .LinkTitle $section) }} + + {{ end }} + {{ end }} - {{ printf `<![CDATA[%s]]>` .Title | safeHTML }}{{ range first 5 (site.RegularPages.Related .) }} - {{ end }} + {{ printf `<![CDATA[%s]]>` .Title | safeHTML }} + {{/* See: https://discourse.gohugo.io/t/using-regularpages-related-gives-me-keywords-index-support-error/35657?u=egrep */}} + {{ $related := first 5 (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }} + {{ range $related }} + + {{ end }} {{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}{{ if ne .Date .Lastmod }} {{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}{{ end }} urn:uuid:{{ substr $uuid 0 8 }}-{{ substr $uuid 8 4 }}-5{{ substr $uuid 13 3 }}-{{ substr $uuid 16 1 }}9{{ substr $uuid 17 2 }}-{{ substr $uuid 21 12 }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 06ef255..0b480fd 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,4 +1,3 @@ -{{/* */}} @@ -6,11 +5,10 @@ {{ block "title" . }}{{- partial "title.html" . -}}{{ end }} - - {{ if or .Params.tags site.Params.seoKeywords }} - - {{ end }} - + + + + {{ hugo.Generator }} {{- partial "styles.html" . }} diff --git a/layouts/partials/keywords.html b/layouts/partials/keywords.html index 275d52d..ab0dd2b 100644 --- a/layouts/partials/keywords.html +++ b/layouts/partials/keywords.html @@ -1,5 +1,13 @@ -{{- if .Params.tags -}} - {{- delimit .Params.tags ", " -}} -{{- else -}} - {{- delimit site.Params.seoKeywords ", " -}} +{{- $keywords := (slice) -}} + +{{- with .Keywords -}} + {{- $keywords = . -}} +{{- else }} + {{- with .Params.tags -}} + {{- $keywords = . -}} + {{- else -}} + {{- $keywords = site.Params.keywords | default slice -}} + {{- end -}} {{- end -}} + +{{- delimit $keywords ", " -}} -- cgit v1.2.3