From da634d62c8ad5ff17885b2370ebd79b4ef4279fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Fri, 19 May 2023 20:44:19 +0200 Subject: [PATCH] theme: allow to display tags below article #513 --- exampleSite/content/basics/customization/_index.en.md | 3 ++- exampleSite/content/basics/migration/_index.en.md | 10 ++++++++++ layouts/_default/taxonomy.html | 2 ++ layouts/_default/term.html | 2 ++ layouts/partials/archetypes/chapter/article.html | 3 +++ layouts/partials/archetypes/default/article.html | 3 +++ .../archetypes/deprecated-chapter/article.html | 3 +++ .../partials/archetypes/deprecated-home/article.html | 3 +++ layouts/partials/archetypes/home/article.html | 3 +++ layouts/partials/body.searchpage.html | 3 ++- layouts/partials/content-footer.html | 4 ++-- layouts/partials/content-header.html | 1 + layouts/partials/header.html | 3 --- static/css/format-print.css | 3 ++- static/css/ie.css | 2 ++ static/css/tags.css | 2 +- static/css/theme.css | 2 ++ 17 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 layouts/partials/content-header.html diff --git a/exampleSite/content/basics/customization/_index.en.md b/exampleSite/content/basics/customization/_index.en.md index f26eab2cc4..ac4f974f34 100644 --- a/exampleSite/content/basics/customization/_index.en.md +++ b/exampleSite/content/basics/customization/_index.en.md @@ -28,7 +28,8 @@ This theme defines the following partials : - `menu-footer.html`: footer of the the left menu - `toc.html`: table of contents - `content.html`: the content page itself. This can be overridden if you want to display page's meta data above or below the content. -- `content-footer`: footer below the content, has a default implementation but you can overwrite it if you don't like it. +- `content-header.html`: header above the title, has a default implementation but you can overwrite it if you don't like it. +- `content-footer.html`: footer below the content, has a default implementation but you can overwrite it if you don't like it. ## Change the logo Create a new file in `layouts/partials/` named `logo.html`. Then write any HTML you want. diff --git a/exampleSite/content/basics/migration/_index.en.md b/exampleSite/content/basics/migration/_index.en.md index c351ef7ce0..e0b941db2b 100644 --- a/exampleSite/content/basics/migration/_index.en.md +++ b/exampleSite/content/basics/migration/_index.en.md @@ -26,6 +26,16 @@ This document shows you what's new in the latest release. For a detailed list of - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The new parameter `breadcrumbSeparator` is now available in your `config.toml` to change the - well - separator of the breadcrumb items. An appropriate default is in place if you do not configure anything. +- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} To give you more flexibility in customizing your article layout a new partial `content-header.html` is introduced. + + This came out of the requirement to customize the position of article tags, which by default is displayed above the title. A second requirement was to also show additional [taxonomies](https://gohugo.io/content-management/taxonomies/) not supported by the theme nativly. While Hugo supports tags and categories by default, the theme only displays tags. + + So how does it work starting from the theme's default where tags are only shown above the title? + + 1. Hide tags above title: Overwrite `content-header.html` with an empty file. + 2. Show tags below title: Overwrite `heading-post.html` and add `{{- partial "tags.html" . }}` to it. + 3. Show tags below article: Overwrite `content-footer.html` and add `{{- partial "tags.html" . }}` to it. + --- ## 5.13.0 (2023-05-17) diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html index 8cbb522f29..8fe2712bcc 100644 --- a/layouts/_default/taxonomy.html +++ b/layouts/_default/taxonomy.html @@ -1,6 +1,8 @@ {{- partialCached "page-meta.hugo" . .RelPermalink }} {{- partial "header.html" . }}
+
+
{{- $page := . }} {{- $title := i18n .Data.Plural }} diff --git a/layouts/_default/term.html b/layouts/_default/term.html index 7aaa8d0b26..5f71eb6a80 100644 --- a/layouts/_default/term.html +++ b/layouts/_default/term.html @@ -1,6 +1,8 @@ {{- partialCached "page-meta.hugo" . .RelPermalink }} {{- partial "header.html" . }}
+
+
{{- $page := . }} {{- $title := i18n .Data.Singular }} diff --git a/layouts/partials/archetypes/chapter/article.html b/layouts/partials/archetypes/chapter/article.html index f71cd3509c..d391efaea6 100644 --- a/layouts/partials/archetypes/chapter/article.html +++ b/layouts/partials/archetypes/chapter/article.html @@ -2,6 +2,9 @@ {{- $content := .content }} {{- with $page }}
+
+ {{- partial "content-header.html" . }} +
{{ partial "heading-pre.html" . }}
{{ T "Chapter" .Params.Weight }}

{{ .Title }}

{{ partial "heading-post.html" . }} diff --git a/layouts/partials/archetypes/default/article.html b/layouts/partials/archetypes/default/article.html index 583de276c1..f3971ab326 100644 --- a/layouts/partials/archetypes/default/article.html +++ b/layouts/partials/archetypes/default/article.html @@ -2,6 +2,9 @@ {{- $content := .content }} {{- with $page }}
+
+ {{- partial "content-header.html" . }} +
{{ partial "heading-pre.html" . }}

{{ .Title }}

{{ partial "heading-post.html" . }} {{ $content | safeHTML }} diff --git a/layouts/partials/archetypes/deprecated-chapter/article.html b/layouts/partials/archetypes/deprecated-chapter/article.html index 997383c03c..84b6059782 100644 --- a/layouts/partials/archetypes/deprecated-chapter/article.html +++ b/layouts/partials/archetypes/deprecated-chapter/article.html @@ -2,6 +2,9 @@ {{- $content := .content }} {{- with $page }}
+
+ {{- partial "content-header.html" . }} +
{{ $content | safeHTML }}