summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-06-16 15:43:50 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-06-18 09:09:56 +0200
commitfc045e12a953aac88b942c25b958c5c0554b252b (patch)
treead8e171d0730f55eb9a531c1a9f0a8dfb51065ad
parent9679023f2b0d7c55b70f23fd94603f301a841079 (diff)
Rename taxonomy kinds from taxonomy to term, taxonomyTerm to taxonomy
And we have taken great measures to limit potential site breakage: * For `disableKinds` and `outputs` we try to map from old to new values if possible, if not we print an ERROR that can be toggled off if not relevant. * The layout lookup is mostly compatible with more options for the new `term` kind. That leaves: * Where queries in site.Pages using taxonomy/taxonomyTerm Kind values as filter. * Other places where these kind value are used in the templates (classes etc.) Fixes #6911 Fixes #7395
-rw-r--r--common/constants/constants.go21
-rw-r--r--common/loggers/ignorableLogger.go52
-rw-r--r--docs/content/en/content-management/taxonomies.md13
-rw-r--r--docs/content/en/getting-started/configuration.md2
-rw-r--r--docs/content/en/templates/lookup-order.md8
-rw-r--r--docs/content/en/templates/output-formats.md12
-rw-r--r--docs/content/en/templates/section-templates.md8
-rw-r--r--docs/data/docs.json272
-rw-r--r--docs/layouts/shortcodes/content-tree.html14
-rw-r--r--docs/layouts/shortcodes/page-kinds.html7
-rw-r--r--hugolib/breaking_changes_test.go141
-rw-r--r--hugolib/cascade_test.go16
-rw-r--r--hugolib/content_map.go6
-rw-r--r--hugolib/content_map_page.go4
-rw-r--r--hugolib/content_map_test.go4
-rw-r--r--hugolib/disableKinds_test.go7
-rw-r--r--hugolib/hugo_sites.go7
-rw-r--r--hugolib/hugo_sites_build_test.go6
-rw-r--r--hugolib/hugo_smoke_test.go2
-rw-r--r--hugolib/page.go10
-rw-r--r--hugolib/page__data.go4
-rw-r--r--hugolib/page__meta.go6
-rw-r--r--hugolib/page__paginator.go2
-rw-r--r--hugolib/page__paths.go2
-rw-r--r--hugolib/page__tree.go2
-rw-r--r--hugolib/page_kinds.go2
-rw-r--r--hugolib/pagebundler_test.go2
-rw-r--r--hugolib/pagecollections_test.go4
-rw-r--r--hugolib/resource_chain_babel_test.go2
-rw-r--r--hugolib/resource_chain_test.go2
-rw-r--r--hugolib/shortcode_test.go2
-rw-r--r--hugolib/site.go55
-rw-r--r--hugolib/site_output.go21
-rw-r--r--hugolib/site_output_test.go22
-rw-r--r--hugolib/site_test.go2
-rw-r--r--hugolib/taxonomy_test.go32
-rw-r--r--hugolib/testhelpers_test.go15
-rw-r--r--output/docshelper.go6
-rw-r--r--output/layout.go12
-rw-r--r--output/layout_test.go16
-rw-r--r--resources/page/page.go2
-rw-r--r--resources/page/page_kinds.go25
-rw-r--r--resources/page/page_kinds_test.go4
-rw-r--r--resources/page/page_paths_test.go10
44 files changed, 644 insertions, 220 deletions
diff --git a/common/constants/constants.go b/common/constants/constants.go
new file mode 100644
index 000000000..25bd7c758
--- /dev/null
+++ b/common/constants/constants.go
@@ -0,0 +1,21 @@
+// Copyright 2020 The Hugo Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package constants
+
+// Error IDs.
+// Do not change these values.
+const (
+ ErrIDAmbigousDisableKindTaxonomy = "error-disable-taxonomy"
+ ErrIDAmbigousOutputKindTaxonomy = "error-output-taxonomy"
+)
diff --git a/common/loggers/ignorableLogger.go b/common/loggers/ignorableLogger.go
new file mode 100644
index 000000000..e12e41d68
--- /dev/null
+++ b/common/loggers/ignorableLogger.go
@@ -0,0 +1,52 @@
+// Copyright 2020 The Hugo Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package loggers
+
+import (
+ "fmt"
+ "strings"
+)
+
+// IgnorableLogger is a logger that ignores certain log statements.
+type IgnorableLogger struct {
+ logger *Logger
+ statements map[string]bool
+}
+
+// NewIgnorableLogger wraps the given logger and ignores the log statement IDs given.
+func NewIgnorableLogger(logger *Logger, statements ...string) IgnorableLogger {
+ statementsSet := make(map[string]bool)
+ for _, s := range statements {
+ statementsSet[strings.ToLower(s)] = true
+
+ }
+ return IgnorableLogger{
+ logger: logger,
+ statements: statementsSet,
+ }
+}
+
+func (l IgnorableLogger) Errorf(statementID, format string, v ...interface{}) {
+ if l.statements[statementID] {
+ // Ignore.
+ return
+ }
+ ignoreMsg := fmt.Sprintf(`
+If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site config:
+ignoreErrors = [%q]`, statementID)
+
+ format += ignoreMsg
+
+ l.logger.ERROR.Printf(format, v...)
+}
diff --git a/docs/content/en/content-management/taxonomies.md b/docs/content/en/content-management/taxonomies.md
index 03747e72b..869193cb3 100644
--- a/docs/content/en/content-management/taxonomies.md
+++ b/docs/content/en/content-management/taxonomies.md
@@ -1,10 +1,9 @@
---
title: Taxonomies
linktitle:
-description: Hugo includes support for user-defined taxonomies to help you demonstrate logical relationships between content for the end users of your website.
+description: Hugo includes support for user-defined taxonomies..
date: 2017-02-01
publishdate: 2017-02-01
-lastmod: 2017-02-01
keywords: [taxonomies,metadata,front matter,terms]
categories: [content management]
menu:
@@ -32,7 +31,6 @@ Term
Value
: a piece of content assigned to a term
-{{< youtube pCPCQgqC8RA >}}
## Example Taxonomy: Movie Website
@@ -97,9 +95,13 @@ Without adding a single line to your [site config][config] file, Hugo will autom
If you do not want Hugo to create any taxonomies, set `disableKinds` in your [site config][config] to the following:
{{< code-toggle copy="false" >}}
-disableKinds = ["taxonomy","taxonomyTerm"]
+disableKinds = ["taxonomy","term"]
{{</ code-toggle >}}
+{{< new-in "0.73.0" >}} We have fixed the before confusing page kinds used for taxonomies (see the listing below) to be in line with the terms used when we talk about taxonomies. We have been careful to avoid site breakage, and you should get an ERROR in the console if you need to adjust your `disableKinds` section.
+
+{{< page-kinds >}}
+
### Default Destinations
When taxonomies are used---and [taxonomy templates][] are provided---Hugo will automatically create both a page listing all the taxonomy's terms and individual pages with lists of content associated with each term. For example, a `categories` taxonomy declared in your configuration and used in your content front matter will create the following pages:
@@ -190,7 +192,7 @@ By using taxonomic weight, the same piece of content can appear in different pos
Currently taxonomies only support the [default `weight => date` ordering of list content](/templates/lists/#default-weight-date). For more information, see the documentation on [taxonomy templates](/templates/taxonomy-templates/).
{{% /note %}}
-## Add custom metadata to a Taxonomy Term
+## Add custom metadata a Taxonomy or Term
If you need to add custom metadata to your taxonomy terms, you will need to create a page for that term at `/content/<TAXONOMY>/<TERM>/_index.md` and add your metadata in it's front matter. Continuing with our 'Actors' example, let's say you want to add a wikipedia page link to each actor. Your terms pages would be something like this:
@@ -201,7 +203,6 @@ If you need to add custom metadata to your taxonomy terms, you will need to crea
---
{{< /code >}}
-You can later use your custom metadata as shown in the [Taxonomy Terms Templates documentation](/templates/taxonomy-templates/#displaying-custom-metadata-in-taxonomy-terms-templates).
[`urlize` template function]: /functions/urlize/
[content section]: /content-management/sections/
diff --git a/docs/content/en/getting-started/configuration.md b/docs/content/en/getting-started/configuration.md
index be46870d6..ffc11938c 100644
--- a/docs/content/en/getting-started/configuration.md
+++ b/docs/content/en/getting-started/configuration.md
@@ -124,7 +124,7 @@ disableHugoGeneratorInject (false)
: Hugo will, by default, inject a generator meta tag in the HTML head on the _home page only_. You can turn it off, but we would really appreciate if you don't, as this is a good way to watch Hugo's popularity on the rise.
disableKinds ([])
-: Enable disabling of all pages of the specified *Kinds*. Allowed values in this list: `"page"`, `"home"`, `"section"`, `"taxonomy"`, `"taxonomyTerm"`, `"RSS"`, `"sitemap"`, `"robotsTXT"`, `"404"`.
+: Enable disabling of all pages of the specified *Kinds*. Allowed values in this list: `"page"`, `"home"`, `"section"`, `"taxonomy"`, `"term"`, `"RSS"`, `"sitemap"`, `"robotsTXT"`, `"404"`.
disableLiveReload (false)
: Disable automatic live reloading of browser window.
diff --git a/docs/content/en/templates/lookup-order.md b/docs/content/en/templates/lookup-order.md
index 629f437c9..e4cb8e552 100644
--- a/docs/content/en/templates/lookup-order.md
+++ b/docs/content/en/templates/lookup-order.md
@@ -41,7 +41,7 @@ Type
: Is value of `type` if set in front matter, else it is the name of the root section (e.g. "blog"). It will always have a value, so if not set, the value is "page".
Section
-: Is relevant for `section`, `taxonomy` and `taxonomyTerm` types.
+: Is relevant for `section`, `taxonomy` and `term` types.
{{% note %}}
**Tip:** The examples below looks long and complex. That is the flexibility talking. Most Hugo sites contain just a handful of templates:
@@ -72,13 +72,13 @@ In Hugo, layouts can live in either the project's or the themes' layout folders,
{{< datatable-filtered "output" "layouts" "Kind == section" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}}
-## Examples: Layout Lookup for Taxonomy List Pages
+## Examples: Layout Lookup for Taxonomy Pages
{{< datatable-filtered "output" "layouts" "Kind == taxonomy" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}}
-## Examples: Layout Lookup for Taxonomy Terms Pages
+## Examples: Layout Lookup for Term Pages
-{{< datatable-filtered "output" "layouts" "Kind == taxonomyTerm" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}}
+{{< datatable-filtered "output" "layouts" "Kind == term" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}}
diff --git a/docs/content/en/templates/output-formats.md b/docs/content/en/templates/output-formats.md
index cbc667da3..619ac449e 100644
--- a/docs/content/en/templates/output-formats.md
+++ b/docs/content/en/templates/output-formats.md
@@ -137,8 +137,8 @@ Formats are set based on that.
| `page` | HTML |
| `home` | HTML, RSS |
| `section` | HTML, RSS |
-| `taxonomyTerm` | HTML, RSS |
-| `taxonomy` | HTML, RSS |
+| `taxonomy` | HTML, RSS |
+| `term` | HTML, RSS |
### Customizing Output Formats
@@ -156,10 +156,14 @@ Example from site config file:
Note that in the above examples, the *output formats* for `section`,
-`taxonomyTerm` and `taxonomy` will stay at their default value `["HTML",
+`taxonomy` and `term` will stay at their default value `["HTML",
"RSS"]`.
-* The `outputs` definition is per [`Page` `Kind`][page_kinds] (`page`, `home`, `section`, `taxonomy`, or `taxonomyTerm`).
+{{< new-in "0.73.0" >}} We have fixed the before confusing page kinds used for taxonomies (see the listing below) to be in line with the terms used when we talk about taxonomies. We have been careful to avoid site breakage, and you should get an ERROR in the console if you need to adjust your `outputs` section.
+
+{{% page-kinds %}}
+
+* The `outputs` definition is per [`Page` `Kind`][page_kinds] (`page`, `home`, `section`, `taxonomy`, or `term`).
* The names (e.g. `HTML`, `AMP`) used must match the `Name` of a defined *Output Format*.
* These names are case insensitive.
* These can be overridden per `Page` in the front matter of content files.
diff --git a/docs/content/en/templates/section-templates.md b/docs/content/en/templates/section-templates.md
index 577529e3f..a40e2a2d7 100644
--- a/docs/content/en/templates/section-templates.md
+++ b/docs/content/en/templates/section-templates.md
@@ -30,13 +30,7 @@ See [Template Lookup](/templates/lookup-order/).
Every `Page` in Hugo has a `.Kind` attribute.
-| Kind | Description | Example |
-|----------------|--------------------------------------------------------------------|-------------------------------------------------------------------------------|
-| `home` | The home page | `/index.html` |
-| `page` | A page showing a _regular page_ | `my-post` page (`/posts/my-post/index.html`) |
-| `section` | A page listing _regular pages_ from a given [_section_][sections] | `posts` section (`/posts/index.html`) |
-| `taxonomy` | A page listing _regular pages_ from a given _taxonomy term_ | page for the term `awesome` from `tags` taxonomy (`/tags/awesome/index.html`) |
-| `taxonomyTerm` | A page listing terms from a given _taxonomy_ | page for the `tags` taxonomy (`/tags/index.html`) |
+{{% page-kinds %}}
## `.Site.GetPage` with Sections
diff --git a/docs/data/docs.json b/docs/data/docs.json
index 01b8b8d54..2a2a0bf52 100644
--- a/docs/data/docs.json
+++ b/docs/data/docs.json
@@ -481,6 +481,17 @@
]
},
{
+ "Name": "Gherkin",
+ "Aliases": [
+ "Cucumber",
+ "FEATURE",
+ "Gherkin",
+ "cucumber",
+ "feature",
+ "gherkin"
+ ]
+ },
+ {
"Name": "Gnuplot",
"Aliases": [
"gnuplot",
@@ -529,6 +540,12 @@
]
},
{
+ "Name": "HLB",
+ "Aliases": [
+ "hlb"
+ ]
+ },
+ {
"Name": "HTML",
"Aliases": [
"htm",
@@ -999,6 +1016,15 @@
]
},
{
+ "Name": "ReasonML",
+ "Aliases": [
+ "re",
+ "reason",
+ "reasonml",
+ "rei"
+ ]
+ },
+ {
"Name": "Rexx",
"Aliases": [
"arexx",
@@ -1028,6 +1054,13 @@
]
},
{
+ "Name": "SAS",
+ "Aliases": [
+ "SAS",
+ "sas"
+ ]
+ },
+ {
"Name": "SCSS",
"Aliases": [
"scss"
@@ -1250,7 +1283,6 @@
"Name": "TypoScript",
"Aliases": [
"ts",
- "txt",
"typoscript"
]
},
@@ -1325,6 +1357,12 @@
]
},
{
+ "Name": "YANG",
+ "Aliases": [
+ "yang"
+ ]
+ },
+ {
"Name": "cfstatement",
"Aliases": [
"cfs"
@@ -1466,6 +1504,7 @@
"keepDefaultAttrVals": true,
"keepDocumentTags": true,
"keepEndTags": true,
+ "keepQuotes": false,
"keepWhitespace": false
},
"css": {
@@ -2257,75 +2296,100 @@
]
},
{
- "Example": "Taxonomy list in categories",
+ "Example": "Taxonomy in categories",
"Kind": "taxonomy",
"OutputFormat": "RSS",
"Suffix": "xml",
"Template Lookup Order": [
- "layouts/categories/category.rss.xml",
+ "layouts/categories/category.terms.rss.xml",
+ "layouts/categories/terms.rss.xml",
"layouts/categories/taxonomy.rss.xml",
"layouts/categories/rss.xml",
"layouts/categories/list.rss.xml",
- "layouts/categories/category.xml",
+ "layouts/categories/category.terms.xml",
+ "layouts/categories/terms.xml",
"layouts/categories/taxonomy.xml",
"layouts/categories/list.xml",
- "layouts/taxonomy/category.rss.xml",
- "layouts/taxonomy/taxonomy.rss.xml",
- "layouts/taxonomy/rss.xml",
- "layouts/taxonomy/list.rss.xml",
- "layouts/taxonomy/category.xml",
- "layouts/taxonomy/taxonomy.xml",
- "layouts/taxonomy/list.xml",
- "layouts/category/category.rss.xml",
+ "layouts/category/category.terms.rss.xml",
+ "layouts/category/terms.rss.xml",
"layouts/category/taxonomy.rss.xml",
"layouts/category/rss.xml",
"layouts/category/list.rss.xml",
- "layouts/category/category.xml",
+ "layouts/category/category.terms.xml",
+ "layouts/category/terms.xml",
"layouts/category/taxonomy.xml",
"layouts/category/list.xml",
- "layouts/_default/category.rss.xml",
+ "layouts/taxonomy/category.terms.rss.xml",
+ "layouts/taxonomy/terms.rss.xml",
+ "layouts/taxonomy/taxonomy.rss.xml",
+ "layouts/taxonomy/rss.xml",
+ "layouts/taxonomy/list.rss.xml",
+ "layouts/taxonomy/category.terms.xml",
+ "layouts/taxonomy/terms.xml",
+ "layouts/taxonomy/taxonomy.xml",
+ "layouts/taxonomy/list.xml",
+ "layouts/_default/category.terms.rss.xml",
+ "layouts/_default/terms.rss.xml",
"layouts/_default/taxonomy.rss.xml",
"layouts/_default/rss.xml",
"layouts/_default/list.rss.xml",
- "layouts/_default/category.xml",
+ "layouts/_default/category.terms.xml",
+ "layouts/_default/terms.xml",
"layouts/_default/taxonomy.xml",
"layouts/_default/list.xml",
"layouts/_internal/_default/rss.xml"
]
},
{
- "Example": "Taxonomy terms in categories",
- "Kind": "taxonomyTerm",
+ "Example": "Term in categories",
+ "Kind": "term",
"OutputFormat": "RSS",
"Suffix": "xml",
"Template Lookup Order": [
- "layouts/categories/category.terms.rss.xml",
- "layouts/categories/terms.rss.xml",
+ "layouts/categories/term.rss.xml",
+ "layouts/categories/category.rss.xml",
+ "layouts/categories/taxonomy.rss.xml",
"layouts/categories/rss.xml",
"layouts/categories/list.rss.xml",
- "layouts/categories/category.terms.xml",
- "layouts/categories/terms.xml",
+ "layouts/categories/term.xml",
+ "layouts/categories/category.xml",
+ "layouts/categories/taxonomy.xml",
"layouts/categories/list.xml",
- "layouts/taxonomy/category.terms.rss.xml",
- "layouts/taxonomy/terms.rss.xml",
+ "layouts/term/term.rss.xml",
+ "layouts/term/category.rss.xml",
+ "layouts/term/taxonomy.rss.xml",
+ "layouts/term/rss.xml",
+ "layouts/term/list.rss.xml",
+ "layouts/term/term.xml",
+ "layouts/term/category.xml",
+ "layouts/term/taxonomy.xml",
+ "layouts/term/list.xml",
+ "layouts/taxonomy/term.rss.xml",
+ "layouts/taxonomy/category.rss.xml",
+ "layouts/taxonomy/taxonomy.rss.xml",
"layouts/taxonomy/rss.xml",
"layouts/taxonomy/list.rss.xml",
- "layouts/taxonomy/category.terms.xml",
- "layouts/taxonomy/terms.xml",
+ "layouts/taxonomy/term.xml",
+ "layouts/taxonomy/category.xml",
+ "layouts/taxonomy/taxonomy.xml",
"layouts/taxonomy/list.xml",
- "layouts/category/category.terms.rss.xml",
- "layouts/category/terms.rss.xml",
+ "layouts/category/term.rss.xml",
+ "layouts/category/category.rss.xml",
+ "layouts/category/taxonomy.rss.xml",
"layouts/category/rss.xml",
"layouts/category/list.rss.xml",
- "layouts/category/category.terms.xml",
- "layouts/category/terms.xml",
+ "layouts/category/term.xml",
+ "layouts/category/category.xml",
+ "layouts/category/taxonomy.xml",
"layouts/category/list.xml",
- "layouts/_default/category.terms.rss.xml",
- "layouts/_default/terms.rss.xml",
+ "layouts/_default/term.rss.xml",
+ "layouts/_default/category.rss.xml",
+ "layouts/_default/taxonomy.rss.xml",
"layouts/_default/rss.xml",
"layouts/_default/list.rss.xml",
- "layouts/_default/category.terms.xml",
- "layouts/_default/terms.xml",
+ "layouts/_default/term.xml",
+ "layouts/_default/category.xml",
+ "layouts/_default/taxonomy.xml",
"layouts/_default/list.xml",
"layouts/_internal/_default/rss.xml"
]
@@ -2426,61 +2490,85 @@
"OutputFormat": "HTML",
"Suffix": "html",
"Template Lookup Order": [
- "layouts/categories/category.html.html",
+ "layouts/categories/category.terms.html.html",
+ "layouts/categories/terms.html.html",
"layouts/categories/taxonomy.html.html",
"layouts/categories/list.html.html",
- "layouts/categories/category.html",
+ "layouts/categories/category.terms.html",
+ "layouts/categories/terms.html",
"layouts/categories/taxonomy.html",
"layouts/categories/list.html",
- "layouts/taxonomy/category.html.html",
- "layouts/taxonomy/taxonomy.html.html",
- "layouts/taxonomy/list.html.html",
- "layouts/taxonomy/category.html",
- "layouts/taxonomy/taxonomy.html",
- "layouts/taxonomy/list.html",
- "layouts/category/category.html.html",
+ "layouts/category/category.terms.html.html",
+ "layouts/category/terms.html.html",
"layouts/category/taxonomy.html.html",
"layouts/category/list.html.html",
- "layouts/category/category.html",
+ "layouts/category/category.terms.html",
+ "layouts/category/terms.html",</