diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-06-05 22:11:41 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-06-05 22:11:41 +0200 |
| commit | 99d814c09d76be0574f78670c7a7080fad95a8f1 (patch) | |
| tree | 3f9cea75a01dfba6f2a4543502ea1f0b64549a5f | |
| parent | 5913da424459f523357b114a683059d3fc4bef68 (diff) | |
| download | gohugo-theme-ed-99d814c09d76be0574f78670c7a7080fad95a8f1.tar.gz | |
Rework site keywords
| -rw-r--r-- | CHANGELOG.md | 8 | ||||
| -rw-r--r-- | exampleSite/config.toml | 36 | ||||
| -rw-r--r-- | layouts/_default/list.atom.xml | 17 | ||||
| -rw-r--r-- | layouts/partials/head.html | 10 | ||||
| -rw-r--r-- | layouts/partials/keywords.html | 16 |
5 files changed, 65 insertions, 22 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index fd92b25..16fcd55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,13 +10,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Rework post dates format. Now they prefixes with "Published on" and "Updated on" -- Rework single post layouts. Reduce the number of layouts for poems, dramas, narratives and posts to one +- Rework single post layouts. Reduce the number of layouts for poems, dramas, + narratives and posts to one +- Rename `site.Params.seoKeywords` to `site.Params.keywords` to match the Hugo + documentation +- Global `site.Params.keywords` may be overridden by `.Params.keywords` or + `.Params.tags` in the post front matter ### Fixed - Fix tags html layout - Add missed `theme-color` meta tag - Enable maskable icon support +- Rework term rendering for Atom feeds to not include duplicates ## [v0.3.0](https://github.com/sergeyklay/gohugo-theme-ed/compare/v0.2.0...v0.3.0) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 8899b90..d763fcd 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -135,25 +135,35 @@ disableKinds = ['RSS'] [params] # Site description. Used in meta description description = 'Ed is a Hugo theme designed for textual editors based on minimal computing principles, and focused on legibility and flexibility.' + # SEO keywords. Used in 'meta name="keywords"' tag. - # May be overridden by page tags. - seoKeywords = ['hugo', 'ed', 'hugo theme', 'minimal', 'responsive', 'clean'] - # Copyright string. "{year}" will be replaced by © and the current year. + # May be overridden by .Keywords or .Tags in front matter. + keywords = ['hugo', 'ed', 'hugo theme', 'minimal', 'responsive', 'clean'] + + # A "copyright"-line to be added to RSS/Atom files. + # "©" and "{year}" will be replaced by © and the current year. copyright = 'Copyright © 2019-{year} John Doe' + # Color scheme. Options: red, orange, magenta, cyan, blue, brown colorScheme = '' + # Used in site header tagline = 'a Hugo theme for minimal editions' + # Custom footer text on left sidebar. Use HTMl if needed. # "{year}" will be replaced by © and the current year. footer = 'Built with <a href="https://github.com/sergeyklay/gohugo-theme-ed" target="_blank" rel="noopener noreferrer">Ed</a>. Distributed under an MIT license.' + # Sections to be displayed in the main page, as well as RSS/Atom feeds mainSections = ['posts', 'dramas', 'narratives', 'poems'] + # Posts date format, for example: 2006-01-02 dateFormat = ':date_long' dateFormatToc = '2006.01.02' + # Show "Read more" button in list if true readmore = true + # RSS/Atom feed size feedSize = 25 recentPostsSize = 5 @@ -161,17 +171,27 @@ disableKinds = ['RSS'] [params.contact] # Forms Backend URL, used in contacts form formAction = 'https://submit-form.com/example' + # Contact form email subject emailSubject = 'Contact form submission' + # After successful submit, where should the user be redirected? thanksUrl = '/thanks' [params.assets] # Site icons, relative to ./static - favicon = '' # favicon.ico for legacy browsers - svgicon = '' # A single SVG icon with a light/dark version for modern browsers - apple_touch_icon = '' # 180×180 PNG image for Apple devices - logo = '/img/open-graph-logo.png' # Logo image, relative to ./assets + + # favicon.ico for legacy browsers + favicon = '' + + # A single SVG icon with a light/dark version for modern browsers + svgicon = '' + + # 180×180 PNG image for Apple devices + apple_touch_icon = '' + + # Logo image, relative to ./assets + logo = '/img/open-graph-logo.png' disable_fingerprinting = false [params.seo] @@ -182,8 +202,10 @@ disableKinds = ['RSS'] [social] # Facebook Page Admin ID for Domain Insights facebook_admin = '' + # Facebook Page ID facebook_id = '' + # Twitter username for the website used in the card footer twitter = 'john_doe' 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 ", " -}} |
