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 --- CHANGELOG.md | 8 +++++++- exampleSite/config.toml | 36 +++++++++++++++++++++++++++++------- layouts/_default/list.atom.xml | 17 +++++++++++++---- layouts/partials/head.html | 10 ++++------ 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 Ed. 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 @@ 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