mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 16:17:21 +00:00
Start of taxonomy docs update for Hugo 0.55
Closes https://github.com/gohugoio/hugo/issues/5843
This commit is contained in:
4 files changed
+66
-81
No files matched your search
@@ -135,24 +135,16 @@ If you want to have just the default `tags` taxonomy, and remove the `categories
|
|||||||
|
|
||||||
If you want to disable all taxonomies altogether, see the use of `disableKinds` in [Hugo Taxonomy Defaults](#default-taxonomies).
|
If you want to disable all taxonomies altogether, see the use of `disableKinds` in [Hugo Taxonomy Defaults](#default-taxonomies).
|
||||||
|
|
||||||
### Preserve Taxonomy Values
|
|
||||||
|
|
||||||
By default, taxonomy names are normalized.
|
|
||||||
|
|
||||||
Therefore, if you want to have a taxonomy term with special characters such as `Gérard Depardieu` instead of `Gerard Depardieu`, set the value for `preserveTaxonomyNames` to `true` in your [site config][config]. Hugo will then preserve special characters in taxonomy values but will still normalize them in URLs.
|
|
||||||
|
|
||||||
Note that if you use `preserveTaxonomyNames` and intend to manually construct URLs to the archive pages, you will need to pass the taxonomy values through the [`urlize` template function][].
|
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
You can add content and front matter to your taxonomy list and taxonomy terms pages. See [Content Organization](/content-management/organization/) for more information on how to add an `_index.md` for this purpose.
|
You can add content and front matter to your taxonomy list and taxonomy terms pages. See [Content Organization](/content-management/organization/) for more information on how to add an `_index.md` for this purpose.
|
||||||
|
|
||||||
Much like regular pages, taxonomy list [permalinks](/content-management/urls/) are configurable, but taxonomy term page permalinks are not.
|
Much like regular pages, taxonomy list [permalinks](/content-management/urls/) are configurable, but taxonomy term page permalinks are not.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
{{% warning "`preserveTaxonomyNames` behaviour change" %}}
|
{{% warning %}}
|
||||||
Before 0.49, Hugo would make the first character upper case for the taxonomy values for titles even if `preserveTaxonomyNames` was active. This no longer the case, which (for instance) makes it possible to have fully lower-case values.
|
The configuration option `preserveTaxonomyNames` was remoted in Hugo 0.55.
|
||||||
|
|
||||||
If you actually need to title-ize these values, you can do so using the `strings.FirstUpper` template function.
|
You can now use `.Page.Title` on the relevant taxonomy node to get the original value.
|
||||||
{{% /warning %}}
|
{{% /warning %}}
|
||||||
|
|
||||||
## Add Taxonomies to Content
|
## Add Taxonomies to Content
|
||||||
|
|||||||
@@ -211,9 +211,6 @@ permalinks
|
|||||||
pluralizeListTitles (true)
|
pluralizeListTitles (true)
|
||||||
: Pluralize titles in lists.
|
: Pluralize titles in lists.
|
||||||
|
|
||||||
preserveTaxonomyNames (false)
|
|
||||||
: Preserve special characters in taxonomy names ("Gérard Depardieu" vs "Gerard Depardieu").
|
|
||||||
|
|
||||||
publishDir ("public")
|
publishDir ("public")
|
||||||
: The directory to where Hugo will write the final static site (the HTML files etc.).
|
: The directory to where Hugo will write the final static site (the HTML files etc.).
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ Usage:
|
|||||||
hugo [command]
|
hugo [command]
|
||||||
|
|
||||||
Available Commands:
|
Available Commands:
|
||||||
benchmark Benchmark Hugo by building a site a number of times.
|
|
||||||
check Contains some verification checks
|
check Contains some verification checks
|
||||||
config Print the site configuration
|
config Print the site configuration
|
||||||
convert Convert your content to different formats
|
convert Convert your content to different formats
|
||||||
@@ -57,43 +56,43 @@ Available Commands:
|
|||||||
version Print the version number of Hugo
|
version Print the version number of Hugo
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-b, --baseURL string hostname (and path) to the root, e.g. http://spf13.com/
|
-b, --baseURL string hostname (and path) to the root, e.g. http://spf13.com/
|
||||||
-D, --buildDrafts include content marked as draft
|
-D, --buildDrafts include content marked as draft
|
||||||
-E, --buildExpired include expired content
|
-E, --buildExpired include expired content
|
||||||
-F, --buildFuture include content with publishdate in the future
|
-F, --buildFuture include content with publishdate in the future
|
||||||
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/
|
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/
|
||||||
--canonifyURLs (deprecated) if true, all relative URLs will be canonicalized using baseURL
|
--cleanDestinationDir remove files from destination not found in static directories
|
||||||
--cleanDestinationDir remove files from destination not found in static directories
|
--config string config file (default is path/config.yaml|json|toml)
|
||||||
--config string config file (default is path/config.yaml|json|toml)
|
--configDir string config dir (default "config")
|
||||||
-c, --contentDir string filesystem path to content directory
|
-c, --contentDir string filesystem path to content directory
|
||||||
--debug debug output
|
--debug debug output
|
||||||
-d, --destination string filesystem path to write files to
|
-d, --destination string filesystem path to write files to
|
||||||
--disableKinds stringSlice disable different kind of pages (home, RSS etc.)
|
--disableKinds strings disable different kind of pages (home, RSS etc.)
|
||||||
--enableGitInfo add Git revision, date and author info to the pages
|
--enableGitInfo add Git revision, date and author info to the pages
|
||||||
--forceSyncStatic copy all files when static is changed.
|
-e, --environment string build environment
|
||||||
--gc enable to run some cleanup tasks (remove unused cache files) after the build
|
--forceSyncStatic copy all files when static is changed.
|
||||||
-h, --help help for hugo
|
--gc enable to run some cleanup tasks (remove unused cache files) after the build
|
||||||
--i18n-warnings print missing translations
|
-h, --help help for hugo
|
||||||
--ignoreCache ignores the cache directory
|
--i18n-warnings print missing translations
|
||||||
-l, --layoutDir string filesystem path to layout directory
|
--ignoreCache ignores the cache directory
|
||||||
--log enable Logging
|
-l, --layoutDir string filesystem path to layout directory
|
||||||
--logFile string log File path (if set, logging enabled automatically)
|
--log enable Logging
|
||||||
--noChmod don't sync permission mode of files
|
--logFile string log File path (if set, logging enabled automatically)
|
||||||
--noTimes don't sync modification time of files
|
--minify minify any supported output format (HTML, XML etc.)
|
||||||
--pluralizeListTitles (deprecated) pluralize titles in lists using inflect (default true)
|
--noChmod don't sync permission mode of files
|
||||||
--preserveTaxonomyNames (deprecated) preserve taxonomy names as written ("Gérard Depardieu" vs "gerard-depardieu")
|
--noTimes don't sync modification time of files
|
||||||
--quiet build in quiet mode
|
--path-warnings print warnings on duplicate target paths etc.
|
||||||
--renderToMemory render to memory (only useful for benchmark testing)
|
--quiet build in quiet mode
|
||||||
-s, --source string filesystem path to read files relative from
|
--renderToMemory render to memory (only useful for benchmark testing)
|
||||||
--stepAnalysis display memory and timing of different steps of the program
|
-s, --source string filesystem path to read files relative from
|
||||||
--templateMetrics display metrics about template executions
|
--templateMetrics display metrics about template executions
|
||||||
--templateMetricsHints calculate some improvement hints when combined with --templateMetrics
|
--templateMetricsHints calculate some improvement hints when combined with --templateMetrics
|
||||||
-t, --theme string theme to use (located in /themes/THEMENAME/)
|
-t, --theme strings themes to use (located in /themes/THEMENAME/)
|
||||||
--themesDir string filesystem path to themes directory
|
--themesDir string filesystem path to themes directory
|
||||||
--uglyURLs (deprecated) if true, use /filename.html instead of /filename/
|
--trace file write trace to file (not useful in general)
|
||||||
-v, --verbose verbose output
|
-v, --verbose verbose output
|
||||||
--verboseLog verbose logging
|
--verboseLog verbose logging
|
||||||
-w, --watch watch filesystem for changes and recreate as needed
|
-w, --watch watch filesystem for changes and recreate as needed
|
||||||
|
|
||||||
Use "hugo [command] --help" for more information about a command.
|
Use "hugo [command] --help" for more information about a command.
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -124,6 +124,18 @@ Taxonomies can be ordered by either alphabetical key or by the number of content
|
|||||||
|
|
||||||
### Order Alphabetically Example
|
### Order Alphabetically Example
|
||||||
|
|
||||||
|
In Hugo 0.55 and later you can do:
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
<ul>
|
||||||
|
{{ range .Data.Terms.Alphabetical }}
|
||||||
|
<li><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> {{ .Count }}</li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
Before that you would have to do something like:
|
||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
<ul>
|
<ul>
|
||||||
{{ $type := .Type }}
|
{{ $type := .Type }}
|
||||||
@@ -137,35 +149,6 @@ Taxonomies can be ordered by either alphabetical key or by the number of content
|
|||||||
</ul>
|
</ul>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Order by Popularity Example
|
|
||||||
|
|
||||||
```go-html-template
|
|
||||||
<ul>
|
|
||||||
{{ $type := .Type }}
|
|
||||||
{{ range $key, $value := .Data.Terms.ByCount }}
|
|
||||||
{{ $name := .Name }}
|
|
||||||
{{ $count := .Count }}
|
|
||||||
{{ with $.Site.GetPage (printf "/%s/%s" $type $name) }}
|
|
||||||
<li><a href="{{ .Permalink }}">{{ $name }}</a> {{ $count }}</li>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
</ul>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Order by Least Popular Example
|
|
||||||
|
|
||||||
```go-html-template
|
|
||||||
<ul>
|
|
||||||
{{ $type := .Type }}
|
|
||||||
{{ range $key, $value := .Data.Terms.ByCount.Reverse }}
|
|
||||||
{{ $name := .Name }}
|
|
||||||
{{ $count := .Count }}
|
|
||||||
{{ with $.Site.GetPage (printf "/%s/%s" $type $name) }}
|
|
||||||
<li><a href="{{ .Permalink }}">{{ $name }}</a> {{ $count }}</li>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
</ul>
|
|
||||||
```
|
|
||||||
|
|
||||||
<!-- [See Also Taxonomy Lists](/templates/list/) -->
|
<!-- [See Also Taxonomy Lists](/templates/list/) -->
|
||||||
|
|
||||||
@@ -311,6 +294,20 @@ The following example displays all terms in a site's tags taxonomy:
|
|||||||
|
|
||||||
### Example: List All Site Tags {#example-list-all-site-tags}
|
### Example: List All Site Tags {#example-list-all-site-tags}
|
||||||
|
|
||||||
|
In Hugo 0.55 and later you can simply do:
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
<ul>
|
||||||
|
{{ range .Site.Taxonomies.tags }}
|
||||||
|
<li><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> {{ .Count }}</li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
Before that you would do something like this:
|
||||||
|
|
||||||
|
{{< todo >}}Clean up rest of the taxonomy examples re Hugo 0.55.{{< /todo >}}
|
||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
<ul id="all-tags">
|
<ul id="all-tags">
|
||||||
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
|
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
|
||||||
|
|||||||
Reference in new issue
Block a user