hugo/docs/content/taxonomies/methods.md
Anthony Fok 5d6dfe81b8 [Docs] Use <dl> for definition lists of variables
Hopefully making them more semantic and easier to read,
though it is raw HTML so it is slightly more work to maintain.

Also made minor revisions to some of the variable descriptions
to be more informative, e.g. `:monthname` in permalinks use
full English names ("January" etc.)
2015-01-19 01:30:38 -07:00

1.6 KiB

date linktitle menu next prev title weight
2014-05-26 Structure & Methods
main
parent
taxonomy
/extras/aliases /taxonomies/ordering Using Taxonomies 75

Hugo makes a set of values and methods available on the various Taxonomy structures.

Taxonomy Methods

A Taxonomy is a map[string]WeightedPages.

.Get(term)
Returns the WeightedPages for a term.
.Count(term)
The number of pieces of content assigned to this term.
.Alphabetical
Returns an OrderedTaxonomy (slice) ordered by Term.
.ByCount
Returns an OrderedTaxonomy (slice) ordered by number of entries.

OrderedTaxonomy

Since Maps are unordered, an OrderedTaxonomy is a special structure that has a defined order.

[]struct {
    Name          string
    WeightedPages WeightedPages
}

Each element of the slice has:

.Term
The Term used.
.WeightedPages
A slice of Weighted Pages.
.Count
The number of pieces of content assigned to this term.
.Pages
All Pages assigned to this term. All list methods are available to this.

WeightedPages

WeightedPages is simply a slice of WeightedPage.

type WeightedPages []WeightedPage
.Count(term)
The number of pieces of content assigned to this term.
.Pages
Returns a slice of pages, which then can be ordered using any of the list methods.