Skip to content

Commit c25bc2a

Browse files
committed
taxonomy: add support for category default taxonomy matcornic#541
1 parent 9222821 commit c25bc2a

File tree

9 files changed

+75
-50
lines changed

9 files changed

+75
-50
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The Relearn theme is a fork of the great [Learn theme](https://github.com/matcor
3131
- In page search
3232
- [Site search](https://mcshelby.github.io/hugo-theme-relearn/basics/configuration#activate-search)
3333
- [Dedicated search page](https://mcshelby.github.io/hugo-theme-relearn/basics/configuration#activate-dedicated-search-page)
34-
- [Tagging support](https://mcshelby.github.io/hugo-theme-relearn/cont/tags)
34+
- [Taxonomy support](https://mcshelby.github.io/hugo-theme-relearn/cont/taxonomy)
3535
- Hidden pages
3636
- Unlimited nested menu dependend on your site structure
3737
- Navigation buttons dependend on your site structure

exampleSite/content/_index.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The theme is a fork of the great [Learn theme](https://github.com/matcornic/hugo
3434
- In page search
3535
- [Site search]({{%relref "basics/configuration#activate-search" %}})
3636
- [Dedicated search page]({{%relref "basics/configuration#activate-dedicated-search-page" %}})
37-
- [Tagging support]({{%relref "cont/tags" %}})
37+
- [Taxonomy support]({{%relref "cont/taxonomy" %}})
3838
- Hidden pages
3939
- Unlimited nested menu dependend on your site structure
4040
- Navigation buttons dependend on your site structure

exampleSite/content/basics/migration/_index.en.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ This document shows you what's new in the latest release. For a detailed list of
1818

1919
---
2020

21+
## 5.16.0 (2023-05-25)
22+
23+
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Besides the _tag_ [taxonomy]({{% relref "cont/taxonomy" %}}) the theme now also provides the _category_ taxonomy out of the box and shows them in the content footer of each page.
24+
25+
---
26+
2127
## 5.15.0 (2023-05-25)
2228

2329
- {{% badge style="note" title=" " %}}Change{{% /badge %}} The [`tabs` shortcode]({{% relref "shortcodes/tabs" %}}) has changed behavior if you haven't set the `groupid` parameter.

exampleSite/content/cont/tags.en.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

exampleSite/content/cont/tags.pir.md

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
+++
2+
categories = ["taxonomy", "content"]
3+
tags = "tutorial"
4+
title = "Taxonomy"
5+
weight = 7
6+
+++
7+
8+
The Relearn theme supports Hugo's default taxonomies *tag* and *category* out of the box.
9+
10+
## Configuration
11+
12+
Just add tags and/or categories to any page. They can be given as a single string or an array of strings.
13+
14+
```toml
15+
+++
16+
categories = ["taxonomy", "content"]
17+
tags = "tutorial"
18+
title = "Taxonomy"
19+
+++
20+
```
21+
22+
## Behavior
23+
24+
The tags are displayed at the top of the page in alphabetical order.
25+
26+
The categories are displayed at the bottom of the page in alphabetical order in the default implementation of the theme but can be customized by providing your own `content-footer.html` partial.
27+
28+
Each item is a link to a taxonomy page displaying all the articles with the given term.
29+
30+
## List all the tags
31+
32+
In the `config.toml` file you can add a shortcut to display all the tags and categories
33+
34+
```toml
35+
[[menu.shortcuts]]
36+
name = "<i class='fas fa-tags'></i> Tags"
37+
url = "/tags"
38+
39+
[[menu.shortcuts]]
40+
name = "<i class='fas fa-list'></i> Categories"
41+
url = "/categories"
42+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
+++
2+
categories = ["taxonomy", "content"]
3+
tags = "tutorrrial"
4+
title = "Taxonomy"
5+
weight = 7
6+
+++
7+
{{< piratify >}}

layouts/partials/content-footer.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,15 @@
33
{{- with $.Date }}
44
<i class='fas fa-calendar'></i> {{ . | time.Format ":date_medium" }}
55
{{- end }}
6-
{{- end }}
6+
{{- end }}
7+
{{- $page := . }}
8+
{{- if .Params.categories }}
9+
<i class='fas fa-list'></i>
10+
{{- $categories := slice | append .Params.categories }}
11+
{{- range $idx, $category := sort $categories }}
12+
{{- with $page.Site.GetPage (printf "%s%s" ("/categories/" | relURL ) ( $category | anchorize ) ) }}
13+
{{- $to := . }}
14+
{{ if gt $idx 0 }} | {{ end }}<a class="tag-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ $category }}</a>
15+
{{- end }}
16+
{{- end }}
17+
{{- end }}

layouts/partials/tags.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
{{- $page := . }}
33
{{- if .Params.tags }}
44
<div class="tags">
5-
{{- range sort .Params.tags }}
6-
{{- $tag := . }}
7-
{{- with $page.Site.GetPage (printf "%s%s" ("/tags/" | relURL ) ( $tag | anchorize ) ) }}
8-
{{- $to := . }}
5+
{{- $tags := slice | append .Params.tags }}
6+
{{- range sort $tags }}
7+
{{- $tag := . }}
8+
{{- with $page.Site.GetPage (printf "%s%s" ("/tags/" | relURL ) ( $tag | anchorize ) ) }}
9+
{{- $to := . }}
910
<a class="tag-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ $tag }}</a>
11+
{{- end }}
1012
{{- end }}
11-
{{- end }}
1213
</div>
1314
{{- end }}

0 commit comments

Comments
 (0)