summaryrefslogtreecommitdiffstats
path: root/layouts
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2022-06-05 22:11:41 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2022-06-05 22:11:41 +0200
commit99d814c09d76be0574f78670c7a7080fad95a8f1 (patch)
tree3f9cea75a01dfba6f2a4543502ea1f0b64549a5f /layouts
parent5913da424459f523357b114a683059d3fc4bef68 (diff)
downloadgohugo-theme-ed-99d814c09d76be0574f78670c7a7080fad95a8f1.tar.gz
Rework site keywords
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/list.atom.xml17
-rw-r--r--layouts/partials/head.html10
-rw-r--r--layouts/partials/keywords.html16
3 files changed, 29 insertions, 14 deletions
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 @@
<id>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 }}</id>{{- range $pages }}
<entry>
{{- $url := .Permalink | absURL }}{{ $uuid := sha1 (.Permalink | absURL) }}{{ $page := . }}
- <category term="{{ .Section }}" />{{ range (.GetTerms "tags") }}
- <category term="{{ .LinkTitle }}" />{{ end }}
+ {{ $section := .Section }}
+ <category term="{{ $section }}" />
+ {{ range (.GetTerms "tags") }}
+ {{ if not (eq .LinkTitle $section) }}
+ <category term="{{ .LinkTitle }}" x="y" />
+ {{ end }}
+ {{ end }}
<link rel="alternate" type="type/html" href="{{ $url }}?utm_source=atom_feed" />
- {{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}{{ range first 5 (site.RegularPages.Related .) }}
- <link href="{{ .Permalink }}?utm_source=atom_feed" rel="related" type="text/html" title="{{ .Title }}" />{{ end }}
+ {{ printf `<title type="html"><![CDATA[%s]]></title>` .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 }}
+ <link href="{{ .Permalink }}?utm_source=atom_feed" rel="related" type="text/html" title="{{ .Title }}" />
+ {{ end }}
<published>{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</published>{{ if ne .Date .Lastmod }}
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>{{ end }}
<id>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 }}</id>
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 @@
-{{/* */}}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,shrink-to-fit=no">
@@ -6,11 +5,10 @@
<link rel="canonical" href="{{ .Permalink }}">
<title>{{ block "title" . }}{{- partial "title.html" . -}}{{ end }}</title>
- <meta name="description" content="{{ (partial "description.html" . ) }}">
- {{ if or .Params.tags site.Params.seoKeywords }}
- <meta name="keywords" content="{{ (partial "keywords.html" . ) }}">
- {{ end }}
- <meta name="author" content="{{ (partial "author.html" . ) }}">
+ <meta name="description" content="{{ partial "description.html" . }}">
+ <meta name="keywords" content="{{ partial "keywords.html" . }}">
+
+ <meta name="author" content="{{ partial "author.html" . }}">
{{ 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 ", " -}}