From bb02a14b1e815eda7e8ecc5db8976ed51e3e3e9f Mon Sep 17 00:00:00 2001 From: spf13 Date: Fri, 29 Aug 2014 23:42:26 -0400 Subject: [PATCH] Adding a page listing the different methods available to Taxonomies. --- docs/content/taxonomies/methods.md | 54 +++++++++++++++++++++++++++++ docs/content/taxonomies/ordering.md | 2 +- docs/content/templates/partials.md | 16 ++++----- 3 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 docs/content/taxonomies/methods.md diff --git a/docs/content/taxonomies/methods.md b/docs/content/taxonomies/methods.md new file mode 100644 index 000000000..d7a3bc3fa --- /dev/null +++ b/docs/content/taxonomies/methods.md @@ -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.
+**.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](/templates/list/) 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](/templates/list/).
+ + + + + + + diff --git a/docs/content/taxonomies/ordering.md b/docs/content/taxonomies/ordering.md index b5e178d98..0db830bbe 100644 --- a/docs/content/taxonomies/ordering.md +++ b/docs/content/taxonomies/ordering.md @@ -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 diff --git a/docs/content/templates/partials.md b/docs/content/templates/partials.md index c8acdd0fe..d08139790 100644 --- a/docs/content/templates/partials.md +++ b/docs/content/templates/partials.md @@ -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 didn’t 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 didn’t 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.