aboutsummaryrefslogtreecommitdiffstats
path: root/content/taxonomies
diff options
context:
space:
mode:
authoretienne <admin@MacBook-Pro-de-Admin.local>2014-10-21 23:35:24 +0200
committeretienne <admin@MacBook-Pro-de-Admin.local>2014-10-21 23:35:24 +0200
commit667e11c4ec3835d959aab1797647bd0a49869674 (patch)
tree84c6c5f20686574009f1dccc0f27a7192ff165e7 /content/taxonomies
Init commit
Diffstat (limited to 'content/taxonomies')
-rw-r--r--content/taxonomies/displaying.md119
-rw-r--r--content/taxonomies/methods.md54
-rw-r--r--content/taxonomies/ordering.md77
-rw-r--r--content/taxonomies/overview.md92
-rw-r--r--content/taxonomies/templates.md25
-rw-r--r--content/taxonomies/usage.md72
6 files changed, 439 insertions, 0 deletions
diff --git a/content/taxonomies/displaying.md b/content/taxonomies/displaying.md
new file mode 100644
index 0000000..d5779ba
--- /dev/null
+++ b/content/taxonomies/displaying.md
@@ -0,0 +1,119 @@
+---
+aliases:
+- /indexes/displaying/
+date: 2013-07-01
+linktitle: Displaying
+menu:
+ main:
+ parent: taxonomy
+next: /taxonomies/templates
+prev: /taxonomies/usage
+title: Displaying Taxonomies
+weight: 20
+---
+
+There are four common ways you can display the data in your
+taxonomies in addition to the automatic taxonomy pages created by hugo
+using the [list templates](/templates/list):
+
+1. For a given piece of content, you can list the terms attached
+2. For a given piece of content, you can list other content with the same
+ term
+3. You can list all terms for a taxonomy
+4. You can list all taxonomies (with their terms)
+
+## 1. Displaying taxonomy terms assigned to this content
+
+Within your content templates, you may wish to display
+the taxonomies that that piece of content is assigned to.
+
+Because we are leveraging the front matter system to
+define taxonomies for content, the taxonomies assigned to
+each content piece are located in the usual place
+(.Params.`plural`).
+
+### Example
+
+ <ul id="tags">
+ {{ range .Params.tags }}
+ <li><a href="tags/{{ . | urlize }}">{{ . }}</a> </li>
+ {{ end }}
+ </ul>
+
+## 2. Listing content with the same taxonomy term
+
+First, you may be asking why you would use this. If you are using a
+taxonomy for something like a series of posts, this is exactly how you
+would do it. It’s also an quick and dirty way to show some related
+content.
+
+
+### Example
+
+ <ul>
+ {{ range .Site.Taxonomies.series.golang }}
+ <li><a href="{{ .Url }}">{{ .Name }}</a></li>
+ {{ end }}
+ </ul>
+
+## 3. Listing all content in a given taxonomy
+
+This would be very useful in a sidebar as “featured content”. You could
+even have different sections of “featured content” by assigning
+different terms to the content.
+
+### Example
+
+ <section id="menu">
+ <ul>
+ {{ range $key, $taxonomy := .Site.Taxonomies.featured }}
+ <li> {{ $key }} </li>
+ <ul>
+ {{ range $taxonomy.Pages }}
+ <li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
+ {{ end }}
+ </ul>
+ {{ end }}
+ </ul>
+ </section>
+
+
+## 4. Rendering a Site's Taxonomies
+
+If you wish to display the list of all keys for an taxonomy, you can find retrieve
+them from the `.Site` variable which is available on every page.
+
+This may take the form of a tag cloud, a menu or simply a list.
+
+The following example displays all tag keys:
+
+### Example
+
+ <ul id="all-tags">
+ {{ range $name, $taxonomy := .Site.Taxonomies.tags }}
+ <li><a href="/tags/{{ $name | urlize }}">{{ $name }}</a></li>
+ {{ end }}
+ </ul>
+
+### Complete Example
+This example will list all taxonomies, each of their keys and all the content assigned to each key.
+
+ <section>
+ <ul>
+ {{ range $taxonomyname, $taxonomy := .Site.Taxonomies }}
+ <li><a href="/{{ $taxonomyname | urlize }}">{{ $taxonomyname }}</a>
+ <ul>
+ {{ range $key, $value := $taxonomy }}
+ <li> {{ $key }} </li>
+ <ul>
+ {{ range $value.Pages }}
+ <li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
+ {{ end }}
+ </ul>
+ {{ end }}
+ </ul>
+ </li>
+ {{ end }}
+ </ul>
+ </section>
+
diff --git a/content/taxonomies/methods.md b/content/taxonomies/methods.md
new file mode 100644
index 0000000..d7a3bc3
--- /dev/null
+++ b/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. <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>
+
+
+
+
+
+
+
diff --git a/content/taxonomies/ordering.md b/content/taxonomies/ordering.md
new file mode 100644
index 0000000..0db830b
--- /dev/null
+++ b/content/taxonomies/ordering.md
@@ -0,0 +1,77 @@
+---
+aliases:
+- /indexes/ordering/
+date: 2013-07-01
+linktitle: Ordering
+menu:
+ main:
+ identifier: Ordering Taxonomies
+ parent: taxonomy
+next: /taxonomies/functions
+prev: /taxonomies/templates
+title: Ordering Taxonomies
+weight: 60
+---
+
+Hugo provides the ability to both:
+
+ 1. Order the way the keys for an taxonomy are displayed
+ 2. Order the way taxonomyed content appears
+
+
+## Ordering Taxonomies
+Taxonomies can be ordered by either alphabetical key or by the number of content pieces assigned to that key.
+
+### Order Alphabetically Example:
+
+ <ul>
+ {{ $data := .Data }}
+ {{ range $key, $value := .Data.Taxonomy.Alphabetical }}
+ <li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
+ {{ end }}
+ </ul>
+
+### Order by Popularity Example:
+
+ <ul>
+ {{ $data := .Data }}
+ {{ range $key, $value := .Data.Taxonomy.ByCount }}
+ <li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
+ {{ end }}
+ </ul>
+
+
+[See Also Taxonomy Lists](/taxonomies/lists/)
+
+## Ordering Content within Taxonomies
+
+Hugo uses both **Date** and **Weight** to order content within taxonomies.
+
+Each piece of content in Hugo can optionally be assigned a date.
+It can also be assigned a weight for each taxonomy it is assigned to.
+
+When iterating over content within taxonomies the default sort is first by weight then by date. This means that if the weights for two pieces of content are the same, than the more recent content will be displayed first. The default weight for any piece of content is 0.
+
+### Assigning Weight
+
+Content can be assigned weight for each taxonomy that it's assigned to.
+
+ +++
+ tags = [ "a", "b", "c" ]
+ tags_weight = 22
+ categories = ["d"]
+ title = "foo"
+ categories_weight = 44
+ +++
+ Front Matter with weighted tags and categories
+
+
+The convention is `taxonomyname_weight`.
+
+In the above example, this piece of content has a weight of 22 which applies to the sorting when rendering the pages assigned to the "a", "b" and "c" values of the 'tag' taxonomy.
+
+It has also been assigned the weight of 44 when rendering the 'd' category.
+
+With this the same piece of content can appear in different positions in different taxonomies.
+
+Currently taxonomies only support the default ordering of content which is weight -> date.
diff --git a/content/taxonomies/overview.md b/content/taxonomies/overview.md
new file mode 100644
index 0000000..579864a
--- /dev/null
+++ b/content/taxonomies/overview.md
@@ -0,0 +1,92 @@
+---
+aliases:
+- /indexes/overview/
+- /doc/indexes/
+- /extras/indexes
+date: 2013-07-01
+linktitle: Overview
+menu:
+ main:
+ identifier: taxonomy overview
+ parent: taxonomy
+next: /taxonomies/usage
+prev: /templates/404
+title: Taxonomy Overview
+weight: 10
+---
+
+Hugo includes support for user defined groupings of content called
+taxonomies. Taxonomies give us a way to classify our content so we can
+demonstrate relationships in a variety of logical ways.
+
+The default taxonomies for Hugo are tags and categories. These
+taxonomies are common to many website systems (WordPress, Drupal,
+Jekyll). Unlike all of those systems, Hugo makes it trivial to customize
+the taxonomies you will be using for your site however you wish. Another
+good use for taxonomies is to group a set of posts into a series. Other
+common uses would include categories, tags, groups, series and many
+more.
+
+When taxonomies are used (and templates are provided), Hugo will
+automatically create pages listing all of the taxonomies, their terms
+and all of the content attached to those terms.
+
+## Definitions
+
+**Taxonomy:** A categorization that can be used to classify content
+
+**Term:** A key within that taxonomy
+
+**Value:** A piece of content assigned to that Term
+
+## Example
+
+For example, if I was writing about movies, I may want the following
+taxonomies:
+
+* Actors
+* Directors
+* Studios
+* Genre
+* Year
+* Awards
+
+I would then specify in each movie’s front-matter the specific terms for
+each of those taxonomies. Hugo would then automatically create pages for
+each Actor, Director, Studio, Genre, Year and Award listing all of the
+Movies that matched that specific Actor, Director, etc.
+
+
+### Taxonomy Organization
+
+Let’s use an example to demonstrate the different labels in action.
+From the perspective of the taxonomy, it could be visualized as:
+
+ Actor <- Taxonomy
+ Bruce Willis <- Term
+ The Six Sense <- Content
+ Unbreakable <- Content
+ Moonrise Kingdom <- Content
+ Samuel L. Jackson <- Term
+ Unbreakable <- Content
+ The Avengers <- Content
+ xXx <- Content
+
+From the perspective of the content, it would appear differently, though
+the data and labels used are the same:
+
+ Unbreakable <- Content
+ Actors <- Taxonomy
+ Bruce Willis <- Term
+ Samuel L. Jackson <- Term
+ Director <- Taxonomy
+ M. Night Shyamalan <- Term
+ ...
+ Moonrise Kingdom <- Content
+ Actors <- Taxonomy
+ Bruce Willis <- Term
+ Bill Murray <- Term
+ Director <- Taxonomy
+ Wes Anderson <- Term
+ ...
+
diff --git a/content/taxonomies/templates.md b/content/taxonomies/templates.md
new file mode 100644
index 0000000..43e27a6
--- /dev/null
+++ b/content/taxonomies/templates.md
@@ -0,0 +1,25 @@
+---
+aliases:
+- /indexes/templates/
+date: 2013-07-01
+linktitle: Templates
+menu:
+ main:
+ parent: taxonomy
+next: /taxonomies/ordering
+prev: /templates/displaying
+title: Taxonomy Templates
+weight: 30
+---
+
+There are two different templates that the use of taxonomies will require you to provide.
+
+Both templates are covered in detail in the templates section.
+
+A [list template](/templates/list/) is any template that will be used to render multiple pieces of
+content in a single html page. This template will be used to generate
+all the automatically created taxonomy pages.
+
+A [taxonomy terms template](/templates/terms/) is a template used to
+generate the list of terms for a given template.
+
diff --git a/content/taxonomies/usage.md b/content/taxonomies/usage.md
new file mode 100644
index 0000000..f55b865
--- /dev/null
+++ b/content/taxonomies/usage.md
@@ -0,0 +1,72 @@
+---
+date: 2014-05-26
+linktitle: Usage
+menu:
+ main:
+ parent: taxonomy
+next: /taxonomies/displaying
+prev: /taxonomies/overview
+title: Using Taxonomies
+weight: 15
+---
+
+## Defining taxonomies for a site
+
+Taxonomies must be defined in the site configuration before they can be
+used throughout the site. You need to provide both the plural and
+singular labels for each taxonomy.
+
+Here is an example configuration in YAML that specifies three taxonomies
+(the default two, plus `series`).
+
+Notice the format is **singular key** : *plural value*.
+### config.yaml
+
+ ---
+ Taxonomies:
+ tag: "tags"
+ category: "categories"
+ series: "series"
+ ---
+
+## Assigning taxonomy values to content
+
+Once an taxonomy is defined at the site level, any piece of content
+can be assigned to it regardless of content type or section.
+
+Assigning content to an taxonomy is done in the front matter.
+Simply create a variable with the *plural* name of the taxonomy
+and assign all terms you want to apply to this content.
+
+**taxonomy values are case insensitive**
+
+### Front Matter Example (in TOML)
+
+ +++
+ title = "Hugo: A fast and flexible static site generator"
+ tags = [ "Development", "Go", "fast", "Blogging" ]
+ categories = [ "Development" ]
+ series = [ "Go Web Dev" ]
+ slug = "hugo"
+ project_url = "http://github.com/spf13/hugo"
+ +++
+
+### Front Matter Example (in JSON)
+
+ {
+ "title": "Hugo: A fast and flexible static site generator",
+ "tags": [
+ "Development",
+ "Go",
+ "fast",
+ "Blogging"
+ ],
+ "categories" : [
+ "Development"
+ ],
+ "series" : [
+ "Go Web Dev"
+ ],
+ "slug": "hugo",
+ "project_url": "http://github.com/spf13/hugo"
+ }