mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
taxonomy: add support for category default taxonomy #541
This commit is contained in:
parent
9222821974
commit
c25bc2a27a
9 changed files with 75 additions and 50 deletions
|
@ -31,7 +31,7 @@ The Relearn theme is a fork of the great [Learn theme](https://github.com/matcor
|
|||
- In page search
|
||||
- [Site search](https://mcshelby.github.io/hugo-theme-relearn/basics/configuration#activate-search)
|
||||
- [Dedicated search page](https://mcshelby.github.io/hugo-theme-relearn/basics/configuration#activate-dedicated-search-page)
|
||||
- [Tagging support](https://mcshelby.github.io/hugo-theme-relearn/cont/tags)
|
||||
- [Taxonomy support](https://mcshelby.github.io/hugo-theme-relearn/cont/taxonomy)
|
||||
- Hidden pages
|
||||
- Unlimited nested menu dependend on your site structure
|
||||
- Navigation buttons dependend on your site structure
|
||||
|
|
|
@ -34,7 +34,7 @@ The theme is a fork of the great [Learn theme](https://github.com/matcornic/hugo
|
|||
- In page search
|
||||
- [Site search]({{%relref "basics/configuration#activate-search" %}})
|
||||
- [Dedicated search page]({{%relref "basics/configuration#activate-dedicated-search-page" %}})
|
||||
- [Tagging support]({{%relref "cont/tags" %}})
|
||||
- [Taxonomy support]({{%relref "cont/taxonomy" %}})
|
||||
- Hidden pages
|
||||
- Unlimited nested menu dependend on your site structure
|
||||
- Navigation buttons dependend on your site structure
|
||||
|
|
|
@ -18,6 +18,12 @@ This document shows you what's new in the latest release. For a detailed list of
|
|||
|
||||
---
|
||||
|
||||
## 5.16.0 (2023-05-25)
|
||||
|
||||
- {{% 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.
|
||||
|
||||
---
|
||||
|
||||
## 5.15.0 (2023-05-25)
|
||||
|
||||
- {{% badge style="note" title=" " %}}Change{{% /badge %}} The [`tabs` shortcode]({{% relref "shortcodes/tabs" %}}) has changed behavior if you haven't set the `groupid` parameter.
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
+++
|
||||
tags = ["documentation", "tutorial stuff"]
|
||||
title = "Tags"
|
||||
weight = 7
|
||||
+++
|
||||
|
||||
The Relearn theme supports one default taxonomy of Hugo: the *tag* feature.
|
||||
|
||||
## Configuration
|
||||
|
||||
Just add tags to any page:
|
||||
|
||||
```toml
|
||||
+++
|
||||
tags = ["tutorial", "theme"]
|
||||
title = "Theme tutorial"
|
||||
weight = 15
|
||||
+++
|
||||
```
|
||||
|
||||
## Behavior
|
||||
|
||||
The tags are displayed at the top of the page, in their insertion order.
|
||||
|
||||
Each tag is a link to a *Taxonomy* page displaying all the articles with the given tag.
|
||||
|
||||
## List all the tags
|
||||
|
||||
In the `config.toml` file you can add a shortcut to display all the tags
|
||||
|
||||
```toml
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fas fa-tags'></i> Tags"
|
||||
url = "/tags"
|
||||
weight = 30
|
||||
```
|
|
@ -1,6 +0,0 @@
|
|||
+++
|
||||
tags = ["documentat'n", "tutorrrial"]
|
||||
title = "Tags"
|
||||
weight = 7
|
||||
+++
|
||||
{{< piratify >}}
|
42
exampleSite/content/cont/taxonomy.en.md
Normal file
42
exampleSite/content/cont/taxonomy.en.md
Normal file
|
@ -0,0 +1,42 @@
|
|||
+++
|
||||
categories = ["taxonomy", "content"]
|
||||
tags = "tutorial"
|
||||
title = "Taxonomy"
|
||||
weight = 7
|
||||
+++
|
||||
|
||||
The Relearn theme supports Hugo's default taxonomies *tag* and *category* out of the box.
|
||||
|
||||
## Configuration
|
||||
|
||||
Just add tags and/or categories to any page. They can be given as a single string or an array of strings.
|
||||
|
||||
```toml
|
||||
+++
|
||||
categories = ["taxonomy", "content"]
|
||||
tags = "tutorial"
|
||||
title = "Taxonomy"
|
||||
+++
|
||||
```
|
||||
|
||||
## Behavior
|
||||
|
||||
The tags are displayed at the top of the page in alphabetical order.
|
||||
|
||||
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.
|
||||
|
||||
Each item is a link to a taxonomy page displaying all the articles with the given term.
|
||||
|
||||
## List all the tags
|
||||
|
||||
In the `config.toml` file you can add a shortcut to display all the tags and categories
|
||||
|
||||
```toml
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fas fa-tags'></i> Tags"
|
||||
url = "/tags"
|
||||
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fas fa-list'></i> Categories"
|
||||
url = "/categories"
|
||||
```
|
7
exampleSite/content/cont/taxonomy.pir.md
Normal file
7
exampleSite/content/cont/taxonomy.pir.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
+++
|
||||
categories = ["taxonomy", "content"]
|
||||
tags = "tutorrrial"
|
||||
title = "Taxonomy"
|
||||
weight = 7
|
||||
+++
|
||||
{{< piratify >}}
|
|
@ -4,3 +4,14 @@
|
|||
<i class='fas fa-calendar'></i> {{ . | time.Format ":date_medium" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $page := . }}
|
||||
{{- if .Params.categories }}
|
||||
<i class='fas fa-list'></i>
|
||||
{{- $categories := slice | append .Params.categories }}
|
||||
{{- range $idx, $category := sort $categories }}
|
||||
{{- with $page.Site.GetPage (printf "%s%s" ("/categories/" | relURL ) ( $category | anchorize ) ) }}
|
||||
{{- $to := . }}
|
||||
{{ if gt $idx 0 }} | {{ end }}<a class="tag-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ $category }}</a>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
{{- $page := . }}
|
||||
{{- if .Params.tags }}
|
||||
<div class="tags">
|
||||
{{- range sort .Params.tags }}
|
||||
{{- $tags := slice | append .Params.tags }}
|
||||
{{- range sort $tags }}
|
||||
{{- $tag := . }}
|
||||
{{- with $page.Site.GetPage (printf "%s%s" ("/tags/" | relURL ) ( $tag | anchorize ) ) }}
|
||||
{{- $to := . }}
|
||||
<a class="tag-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ $tag }}</a>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</div>
|
||||
{{- end }}
|
Loading…
Reference in a new issue