2014-08-30 03:42:26 +00:00
|
|
|
---
|
|
|
|
date: 2014-05-26
|
|
|
|
linktitle: Structure & Methods
|
|
|
|
menu:
|
|
|
|
main:
|
|
|
|
parent: taxonomy
|
|
|
|
next: /extras/aliases
|
|
|
|
prev: /taxonomies/ordering
|
|
|
|
title: Using Taxonomies
|
|
|
|
weight: 75
|
|
|
|
---
|
|
|
|
|
|
|
|
Hugo makes a set of values and methods available on the various Taxonomy structures.
|
|
|
|
|
|
|
|
## Taxonomy Methods
|
|
|
|
|
|
|
|
A Taxonomy is a `map[string]WeightedPages`.
|
|
|
|
|
2015-01-19 18:44:14 +00:00
|
|
|
**.Get(term)** Returns the WeightedPages for a term. <br>
|
|
|
|
**.Count(term)** The number of pieces of content assigned to this term.<br>
|
|
|
|
**.Alphabetical** Returns an OrderedTaxonomy (slice) ordered by Term. <br>
|
|
|
|
**.ByCount** Returns an OrderedTaxonomy (slice) ordered by number of entries. <br>
|
2014-08-30 03:42:26 +00:00
|
|
|
|
|
|
|
## 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:
|
|
|
|
|
2015-01-19 18:44:14 +00:00
|
|
|
**.Term** The Term used.<br>
|
|
|
|
**.WeightedPages** A slice of Weighted Pages.<br>
|
|
|
|
**.Count** The number of pieces of content assigned to this term.<br>
|
|
|
|
**.Pages** All Pages assigned to this term. All [list methods](/templates/list/) are available to this.<br>
|
2014-08-30 03:42:26 +00:00
|
|
|
|
|
|
|
## WeightedPages
|
|
|
|
|
|
|
|
WeightedPages is simply a slice of WeightedPage.
|
|
|
|
|
|
|
|
type WeightedPages []WeightedPage
|
|
|
|
|
2015-01-19 18:44:14 +00:00
|
|
|
**.Count(term)** The number of pieces of content assigned to this term.<br>
|
|
|
|
**.Pages** Returns a slice of pages, which then can be ordered using any of the [list methods](/templates/list/). <br>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|