mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-11 05:54:58 +00:00
Merge commit 'f3cd083961f36dc96d05e98aaf67f650102bc757'
This commit is contained in:
@@ -101,7 +101,7 @@ Go templates only ship with a few basic functions but also provide a mechanism f
|
||||
=> true (i.e., since 1 is less than 2)
|
||||
```
|
||||
|
||||
Note that both examples make us of Go template's [math functions][].
|
||||
Note that both examples make use of Go template's [math functions][].
|
||||
|
||||
{{% note "Additional Boolean Operators" %}}
|
||||
There are more boolean operators than those listed in the Hugo docs in the [Golang template documentation](http://golang.org/pkg/text/template/#hdr-Functions).
|
||||
|
||||
@@ -37,8 +37,6 @@ This is the full set of built-in media types in Hugo:
|
||||
|
||||
To add or modify a media type, define it in a `mediaTypes` section in your [site configuration][config], either for all sites or for a given language.
|
||||
|
||||
Example in `config.toml`:
|
||||
|
||||
```
|
||||
[mediaTypes]
|
||||
[mediaTypes."text/enriched"]
|
||||
@@ -49,6 +47,21 @@ Example in `config.toml`:
|
||||
|
||||
The above example adds one new media type, `text/enriched`, and changes the suffix for the built-in `text/html` media type.
|
||||
|
||||
**Note:** these media types are configured for **your output formats**. If you want to redefine one of Hugo's default output formats (e.g. `HTML`), you also need to redefine the output format. So, if you want to change the suffix of the `HTML` output format from `html` (default) to `htm`:
|
||||
|
||||
```toml
|
||||
[mediaTypes]
|
||||
[mediaTypes."text/html"]
|
||||
suffix = "htm"
|
||||
|
||||
# Redefine HTML to update its media type.
|
||||
[outputFormats]
|
||||
[outputFormats.HTML]
|
||||
mediaType = "text/html"
|
||||
```
|
||||
|
||||
**Note** that for the above to work, you also need to add an`outputs` definition in your site config.
|
||||
|
||||
## Output Formats
|
||||
|
||||
Given a media type and some additional configuration, you get an `Output Format`:
|
||||
@@ -61,7 +74,7 @@ This is the full set of Hugo's built-in output formats:
|
||||
* The `MediaType` must match the `Type` of an already defined media type.
|
||||
* You can define new output formats or redefine built-in output formats; e.g., if you want to put `AMP` pages in a different path.
|
||||
|
||||
To add or modify an output format, define it in an `outputFormats` section in your site's [configuration file](/templates/configuration/), either for all sites or for a given language.
|
||||
To add or modify an output format, define it in an `outputFormats` section in your site's [configuration file](/getting-started/configuration/), either for all sites or for a given language.
|
||||
|
||||
```
|
||||
[outputFormats.MyEnrichedFormat]
|
||||
|
||||
@@ -78,6 +78,9 @@ A Taxonomy is a `map[string]WeightedPages`.
|
||||
.ByCount
|
||||
: Returns an OrderedTaxonomy (slice) ordered by number of entries.
|
||||
|
||||
.Reverse
|
||||
: Returns an OrderedTaxonomy (slice) in reverse order. Must be used with an OrderedTaxonomy.
|
||||
|
||||
### OrderedTaxonomy
|
||||
|
||||
Since Maps are unordered, an OrderedTaxonomy is a special structure that has a defined order.
|
||||
@@ -160,6 +163,17 @@ Taxonomies can be ordered by either alphabetical key or by the number of content
|
||||
</ul>
|
||||
```
|
||||
|
||||
### Order by Least Popular Example
|
||||
|
||||
```
|
||||
<ul>
|
||||
{{ $data := .Data }}
|
||||
{{ range $key, $value := .Data.Terms.ByCount.Reverse }}
|
||||
<li><a href="{{ $.Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
```
|
||||
|
||||
<!-- [See Also Taxonomy Lists](/templates/list/) -->
|
||||
|
||||
## Order Content within Taxonomies
|
||||
|
||||
Reference in New Issue
Block a user