mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-18 10:50:24 +00:00
docs: revise custom taxonomies #567
This commit is contained in:
parent
3fa95990ee
commit
d8f5a9128f
9 changed files with 57 additions and 64 deletions
|
@ -34,7 +34,7 @@ The Relearn theme is an enhanced fork of the popular [Learn theme](https://githu
|
|||
- [Unlimited nested menu structure](https://mcshelby.github.io/hugo-theme-relearn/content/organization)
|
||||
- [Configurable menu shortcuts](https://mcshelby.github.io/hugo-theme-relearn/configuration/sidebar/shortcutmenu/)
|
||||
- Support for hidden pages
|
||||
- [Comprehensive taxonomy support](https://mcshelby.github.io/hugo-theme-relearn/content/taxonomy)
|
||||
- [Comprehensive taxonomy support](https://mcshelby.github.io/hugo-theme-relearn/configuration/modifications/taxonomy)
|
||||
- [Social media integration](https://mcshelby.github.io/hugo-theme-relearn/configuration/content/image/)
|
||||
|
||||
- **Multilingual Support**
|
||||
|
|
|
@ -113,22 +113,22 @@ summaryLength = 10
|
|||
|
||||
[[languages.en.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-camera'></i> Showcases"
|
||||
pageRef = "showcase/"
|
||||
pageRef = "/showcase"
|
||||
weight = 20
|
||||
|
||||
[[languages.en.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-bullhorn'></i> Credits"
|
||||
pageRef = "more/credits/"
|
||||
pageRef = "/more/credits"
|
||||
weight = 30
|
||||
|
||||
[[languages.en.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-tags'></i> Tags"
|
||||
pageRef = "tags/"
|
||||
pageRef = "/tags"
|
||||
weight = 40
|
||||
|
||||
[[languages.en.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-layer-group'></i> Categories"
|
||||
pageRef = "categories/"
|
||||
pageRef = "/categories"
|
||||
weight = 50
|
||||
|
||||
# this is ourrr way t' showcase th' multilang settings by
|
||||
|
@ -159,22 +159,22 @@ summaryLength = 10
|
|||
|
||||
[[languages.pir.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-camera'></i> Showcases"
|
||||
pageRef = "showcase/"
|
||||
pageRef = "/showcase"
|
||||
weight = 20
|
||||
|
||||
[[languages.pir.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-bullhorn'></i> Crrredits"
|
||||
pageRef = "more/credits/"
|
||||
pageRef = "/more/credits"
|
||||
weight = 30
|
||||
|
||||
[[languages.pir.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-tags'></i> Arrr! Tags"
|
||||
pageRef = "tags/"
|
||||
pageRef = "/tags"
|
||||
weight = 40
|
||||
|
||||
[[languages.pir.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-layer-group'></i> Categorrries"
|
||||
pageRef = "categories/"
|
||||
pageRef = "/categories"
|
||||
weight = 50
|
||||
|
||||
# mounts are only needed in this showcase to access the publicly available screenshots and CHANGELOG;
|
||||
|
|
|
@ -1,52 +1,44 @@
|
|||
+++
|
||||
categories = ["taxonomy", "content"]
|
||||
description = "How to display custom taxonomies on your pages"
|
||||
tags = "tutorial"
|
||||
title = "Taxonomy"
|
||||
title = "Custom Taxonomies"
|
||||
weight = 5
|
||||
+++
|
||||
|
||||
The Relearn theme supports Hugo's default taxonomies _tag_ and _category_ out of the box.
|
||||
This page shows you how customize your templates to display custom taxonomies on your pages.
|
||||
|
||||
## Configuration
|
||||
See the official documentation on [how to configure custom taxnomies](https://gohugo.io/content-management/taxonomies/#configure-taxonomies) and [how to use them in your page's front matter](https://gohugo.io/content-management/taxonomies/#assign-terms-to-content).
|
||||
|
||||
Just add tags and/or categories to any page. They can be given as a single string or an array of strings.
|
||||
## Standard Behavior
|
||||
|
||||
{{< multiconfig fm=true >}}
|
||||
categories = ["taxonomy", "content"]
|
||||
tags = "tutorial"
|
||||
title = "Taxonomy"
|
||||
{{< /multiconfig >}}
|
||||
The Relearn theme displays Hugo's [default taxonomies](https://gohugo.io/content-management/taxonomies/#default-taxonomies) _tag_ and _category_ out of the box.
|
||||
|
||||
## Behavior
|
||||
The _tags_ are displayed at the top of the page in alphabetical order.
|
||||
|
||||
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.
|
||||
The _categories_ are displayed at the bottom of the page in alphabetical order.
|
||||
|
||||
Each item is a link to a taxonomy page displaying all the articles with the given term.
|
||||
|
||||
## List all the tags
|
||||
## Configuration
|
||||
|
||||
In the `hugo.toml` file you can add a shortcut to display all the tags and categories
|
||||
To add custom taxnomies, you have to configure them in your `hugo.toml` and also have to add the default taxonomies if you want to use them.
|
||||
|
||||
{{< multiconfig file=hugo >}}
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-tags'></i> Tags"
|
||||
url = "/tags"
|
||||
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-layer-group'></i> Categories"
|
||||
url = "/categories"
|
||||
[taxonomies]
|
||||
category = 'categories'
|
||||
mycustomtag = 'mycustomtags'
|
||||
tag = 'tags'
|
||||
{{< /multiconfig >}}
|
||||
|
||||
## Customization
|
||||
|
||||
If you define [custom taxonomies](https://gohugo.io/content-management/taxonomies/#configure-taxonomies) and want to display a list of them somewhere on your page (often in the `layouts/partials/content-footer.html`) you can call a partial that does the job for you:
|
||||
You can display the terms of your custom taxonomy somewhere in your page (often in the `layouts/partials/content-footer.html`) by calling a partial that does the job for you
|
||||
|
||||
````go
|
||||
{{ partial "term-list.html" (dict
|
||||
"page" .
|
||||
"taxonomy" "categories"
|
||||
"taxonomy" "mycustomtags"
|
||||
"icon" "layer-group"
|
||||
) }}
|
||||
````
|
|
@ -1,7 +1,8 @@
|
|||
+++
|
||||
categories = ["taxonomy", "content"]
|
||||
description = "How to display custom taxonomies on your pages"
|
||||
tags = "tutorrrial"
|
||||
title = "Taxonomy"
|
||||
title = "Custom Taxonomies"
|
||||
weight = 5
|
||||
+++
|
||||
{{< piratify >}}
|
|
@ -7,11 +7,11 @@ weight = 5
|
|||
|
||||
The sidebar contains the navigation menu of your content files but you can also add additional menu entries or shortcuts below the navigation menu.
|
||||
|
||||
You can read more about [Hugo's menu configuration](https://gohugo.io/content-management/menus/#define-in-site-configuration) in its documenation.
|
||||
Be sure to use the `pageRef` property instead of `url` for all links internal to your site. You can read more about [Hugo's menu configuration](https://gohugo.io/content-management/menus/#define-in-site-configuration) in its documenation.
|
||||
|
||||
## Title
|
||||
|
||||
By default, the shortcut menu is preceded by a title. This title can be disabled by setting `params.disableShortcutsTitle=true`. However, if you want to keep the title but change its value, it can be overridden by changing your local i18n translation string configuration.
|
||||
By default, the shortcut menu is preceded by a title ("_More_" in the english translation). This title can be disabled by setting `params.disableShortcutsTitle=true`. However, if you want to keep the title but change its value, it can be overridden by changing your local i18n translation string configuration.
|
||||
|
||||
For example, in your local `i18n/en.toml` file, add the following content
|
||||
|
||||
|
@ -26,31 +26,31 @@ Edit the `hugo.toml` and add a `[[menu.shortcuts]]` entry for each link your wan
|
|||
|
||||
{{< multiconfig file=hugo >}}
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fa-fw fab fa-github'></i> GitHub repo"
|
||||
identifier = "ds"
|
||||
url = "https://github.com/McShelby/hugo-theme-relearn"
|
||||
weight = 10
|
||||
name = "<i class='fa-fw fab fa-github'></i> GitHub repo"
|
||||
identifier = "ds"
|
||||
url = "https://github.com/McShelby/hugo-theme-relearn"
|
||||
weight = 10
|
||||
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-camera'></i> Showcases"
|
||||
url = "showcase/"
|
||||
weight = 11
|
||||
name = "<i class='fa-fw fas fa-camera'></i> Showcases"
|
||||
pageRef = "/showcase"
|
||||
weight = 11
|
||||
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-bookmark'></i> Hugo Documentation"
|
||||
identifier = "hugodoc"
|
||||
url = "https://gohugo.io/"
|
||||
weight = 20
|
||||
name = "<i class='fa-fw fas fa-bookmark'></i> Hugo Documentation"
|
||||
identifier = "hugodoc"
|
||||
url = "https://gohugo.io/"
|
||||
weight = 20
|
||||
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-bullhorn'></i> Credits"
|
||||
url = "more/credits/"
|
||||
weight = 30
|
||||
name = "<i class='fa-fw fas fa-bullhorn'></i> Credits"
|
||||
pageRef = "/more/credits"
|
||||
weight = 30
|
||||
|
||||
[[menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-tags'></i> Tags"
|
||||
url = "tags/"
|
||||
weight = 40
|
||||
name = "<i class='fa-fw fas fa-tags'></i> Tags"
|
||||
pageRef = "/tags"
|
||||
weight = 40
|
||||
{{< /multiconfig >}}
|
||||
|
||||
## Multilingual Example
|
||||
|
@ -74,7 +74,7 @@ When using a multilingual website, you can set different menus for each language
|
|||
|
||||
[[languages.en.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-camera'></i> Showcases"
|
||||
pageRef = "showcase/"
|
||||
pageRef = "/showcase"
|
||||
weight = 11
|
||||
|
||||
[[languages.en.menu.shortcuts]]
|
||||
|
@ -85,12 +85,12 @@ When using a multilingual website, you can set different menus for each language
|
|||
|
||||
[[languages.en.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-bullhorn'></i> Credits"
|
||||
pageRef = "more/credits/"
|
||||
pageRef = "/more/credits"
|
||||
weight = 30
|
||||
|
||||
[[languages.en.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-tags'></i> Tags"
|
||||
pageRef = "tags/"
|
||||
pageRef = "/tags"
|
||||
weight = 40
|
||||
|
||||
[languages.pir]
|
||||
|
@ -108,7 +108,7 @@ When using a multilingual website, you can set different menus for each language
|
|||
|
||||
[[languages.pir.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-camera'></i> Showcases"
|
||||
pageRef = "showcase/"
|
||||
pageRef = "/showcase"
|
||||
weight = 11
|
||||
|
||||
[[languages.pir.menu.shortcuts]]
|
||||
|
@ -119,16 +119,16 @@ When using a multilingual website, you can set different menus for each language
|
|||
|
||||
[[languages.pir.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-bullhorn'></i> Crrredits"
|
||||
pageRef = "more/credits/"
|
||||
pageRef = "/more/credits"
|
||||
weight = 30
|
||||
|
||||
[[languages.pir.menu.shortcuts]]
|
||||
name = "<i class='fa-fw fas fa-tags'></i> Arrr! Tags"
|
||||
pageRef = "tags/"
|
||||
pageRef = "/tags"
|
||||
weight = 40
|
||||
{{< /multiconfig >}}
|
||||
|
||||
## Shortcuts to Pages Inside of your Project
|
||||
## How to Display Pages Only in the Shortcuts Menu
|
||||
|
||||
If you have shortcuts to pages inside of your project and you don't want them to show up in your navigation menu, you have two choices:
|
||||
|
||||
|
|
|
@ -26,4 +26,4 @@ weight = -15
|
|||
|
||||
Additionally for such a use case, the whitespace between a tab outline and the code is removed if only a single code block is contained.
|
||||
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Besides the _tag_ [taxonomy](content/taxonomy) the theme now also provides the _category_ taxonomy out of the box and shows them in the content footer of each page.
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Besides the _tag_ [taxonomy](configuration/modifications/taxonomy) the theme now also provides the _category_ taxonomy out of the box and shows them in the content footer of each page.
|
||||
|
|
|
@ -18,7 +18,7 @@ weight = -22
|
|||
|
||||
This can come in handy, if content for such a section page doesn't make much sense to you. See [the documentation](content/frontmatter#disable-section-pages) for how to do this.
|
||||
|
||||
This feature may require you to make changes to your existing installation if you are already using _[shortcuts to pages inside of your project](configuration/sidebar/shortcutmenu/#shortcuts-to-pages-inside-of-your-project)_ with a _headless branch parent_.
|
||||
This feature may require you to make changes to your existing installation if you are already using _[shortcuts to pages inside of your project](configuration/sidebar/shortcutmenu/#how-to-display-pages-only-in-the-shortcuts-menu)_ with a _headless branch parent_.
|
||||
|
||||
In this case it is advised to remove the `title` from the headless branch parent's frontmatter, as it will otherwise appear in your breadcrumbs.
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ weight = -23
|
|||
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Taxonomy and term pages are now allowed to contain content. This is added inbetween the title and the page list.
|
||||
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} It is now possible to print custom taxonomies anywhere in your page. [See the docs](content/taxonomy#customization).
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} It is now possible to print custom taxonomies anywhere in your page. [See the docs](configuration/modifications/taxonomy#customization).
|
||||
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} It is now possible to adjust the menu width for your whole site. [See the docs](configuration/sidebar/width/).
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ weight = -9
|
|||
|
||||
It was later discovered, that this causes pages only meant to be displayed in the `More` section of the menu and stored directly inside your `content` directory to now show up in the menu as well.
|
||||
|
||||
To [get rid](configuration/sidebar/shortcutmenu/#shortcuts-to-pages-inside-of-your-project) of this undesired behavior you have two choices:
|
||||
To [get rid](configuration/sidebar/shortcutmenu/#how-to-display-pages-only-in-the-shortcuts-menu) of this undesired behavior you have two choices:
|
||||
|
||||
1. Make the page file a [headless branch bundle](https://gohugo.io/content-management/page-bundles/#headless-bundle) (contained in its own subdirectory and called `_index.md`) and add the following frontmatter configuration to the file (see exampleSite's `content/showcase/_index.en.md`). This causes its content to **not** be ontained in the sitemap.
|
||||
|
||||
|
|
Loading…
Reference in a new issue