From c95069990795965c34059b6844fe9fa5125be7c1 Mon Sep 17 00:00:00 2001 From: Anton Staaf Date: Sun, 5 Mar 2017 12:24:14 -0800 Subject: [PATCH] hugolib: Populate the taxonomy term Pages list Previously this was left empty, but it is very handy to have a list of term pages for a given taxonomy. This list can now be paginated like other page lists. It makes it possible to render summary content from each terms index page for instance. It also makes it possible to sort the term pages in the same way that other page lists can be sorted. An RSS feed is now generated for KindTaxonomyTerm pages as well. This also fixes a bug in HugoSites.createMissingPages. Previously it would only check for existing KindTaxonomyTerm pages if the taxonomy had any terms defined. So for a taxonomy with no terms but a taxonomy terms page it would generate a second empty terms page. --- docs/content/templates/rss.md | 8 ++++++++ docs/content/templates/terms.md | 14 +++++++++++++- hugolib/node_as_page_test.go | 10 +++++++++- hugolib/page.go | 11 ++++++++++- hugolib/site.go | 2 +- hugolib/site_render.go | 2 +- hugolib/taxonomy_test.go | 22 ++++++++++++++++++---- 7 files changed, 60 insertions(+), 9 deletions(-) diff --git a/docs/content/templates/rss.md b/docs/content/templates/rss.md index d390b4306..fe445469a 100644 --- a/docs/content/templates/rss.md +++ b/docs/content/templates/rss.md @@ -48,6 +48,14 @@ Hugo will use the following prioritized list. If a file isn’t present, then th * /themes/`THEME`/layouts/\_default/rss.xml * [Embedded rss.xml](#the-embedded-rss-xml:eceb479b7b3b2077408a2878a29e1320) +### Taxonomy Terms RSS + +* /layouts/taxonomy/`SINGULAR`.terms.rss.xml +* /layouts/\_default/rss.xml +* /themes/`THEME`/layouts/taxonomy/`SINGULAR`.terms.rss.xml +* /themes/`THEME`/layouts/\_default/rss.xml +* [Embedded rss.xml](#the-embedded-rss-xml:eceb479b7b3b2077408a2878a29e1320) + ## Configuring RSS diff --git a/docs/content/templates/terms.md b/docs/content/templates/terms.md index 378bd4df8..f81fc8f71 100644 --- a/docs/content/templates/terms.md +++ b/docs/content/templates/terms.md @@ -57,6 +57,7 @@ Taxonomy Terms pages will additionally have: * **.Data.Singular** The singular name of the taxonomy * **.Data.Plural** The plural name of the taxonomy +* **.Data.Pages** (or as **.Pages**) The taxonomy Terms index pages * **.Data.Terms** The taxonomy itself * **.Data.Terms.Alphabetical** The Terms alphabetized * **.Data.Terms.ByCount** The Terms ordered by popularity @@ -121,7 +122,7 @@ Another example listing the content for each term (ordered by Date): ## Ordering -Hugo can order the meta data in two different ways. It can be ordered: +Hugo can order the term meta data in two different ways. It can be ordered: * by the number of contents assigned to that key, or * alphabetically. @@ -162,3 +163,14 @@ Hugo can order the meta data in two different ways. It can be ordered: {{ partial "footer.html" . }} + +Hugo can also order and paginate the term index pages in all the normal ways. + +### Example terms.html snippet (paginated and ordered by date) + +

{{ .Title }}

+ diff --git a/hugolib/node_as_page_test.go b/hugolib/node_as_page_test.go index f063faf9a..57a51f40a 100644 --- a/hugolib/node_as_page_test.go +++ b/hugolib/node_as_page_test.go @@ -176,7 +176,10 @@ func doTestNodeAsPage(t *testing.T, ugly, preserveTaxonomyNames bool) { "Lastmod: 2009-01-15", ) - // There are no pages to paginate over in the taxonomy terms. + // Check taxonomy terms paginator + th.assertFileContent(expectedFilePath(ugly, "public", "categories", "page", "2"), + "Taxonomy Terms Title: Taxonomy Term Categories", + "Pag: Taxonomy Web") // RSS th.assertFileContent(filepath.Join("public", "customrss.xml"), "Recent content in Home Sweet Home! on Hugo Rocks", "