Adding a page listing the different methods available to Taxonomies.

This commit is contained in:
spf13 2014-08-29 23:42:26 -04:00
parent ba8f652acc
commit bb02a14b1e
3 changed files with 62 additions and 10 deletions

View file

@ -0,0 +1,54 @@
---
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`.
**.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>
## 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.<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>
## WeightedPages
WeightedPages is simply a slice of WeightedPage.
type WeightedPages []WeightedPage
**.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>

View file

@ -7,7 +7,7 @@ menu:
main:
identifier: Ordering Taxonomies
parent: taxonomy
next: /extras/aliases
next: /taxonomies/functions
prev: /taxonomies/templates
title: Ordering Taxonomies
weight: 60

View file

@ -11,19 +11,17 @@ title: Partial Templates
weight: 80
---
It's not a requirement to have this, but in practice it's very
convenient to split out common template portions into a partial template
that can be included anywhere. As you create the rest of your templates
you will include templates from the /layout/partials directory.
In practice it's very convenient to split out common template portions into a
partial template that can be included anywhere. As you create the rest of your
templates you will include templates from the /layout/partials directory.
Partials are especially important for themes as it gives users an opportunity
to overwrite just a small part of your theme, while maintaining future compatibility.
In fact theme developers may want to include a few partials with empty html
Theme developers may want to include a few partials with empty html
files in the theme just so end users have an easy place to inject their
customized content.
I've found it helpful to include a header and footer template in
partials so I can include those in all the full page layouts. There is
nothing special about header.html and footer.html other than they seem
@ -41,9 +39,9 @@ used for both nodes and pages we can use the same partials for both.
Version v0.12 of Hugo introduced the partial call inside the template system.
This is a change to the way partials were handled previously inside the
template system. This is a change to hthe way partials were handled previously.
Previously Hugo didnt treat partials specially and you could include a partial
template with the `template` call in the standard template language.
template system. In earlier versions, Hugo didnt treat partials specially and
you could include a partial template with the `template` call in the standard
template language.
With the addition of the theme system in v0.11 it became apparent that a theme
& override aware partial was needed.