diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-06-16 15:43:50 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-06-18 09:09:56 +0200 |
commit | fc045e12a953aac88b942c25b958c5c0554b252b (patch) | |
tree | ad8e171d0730f55eb9a531c1a9f0a8dfb51065ad /hugolib | |
parent | 9679023f2b0d7c55b70f23fd94603f301a841079 (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
Diffstat (limited to 'hugolib')
27 files changed, 294 insertions, 86 deletions
diff --git a/hugolib/breaking_changes_test.go b/hugolib/breaking_changes_test.go new file mode 100644 index 000000000..c935d6e93 --- /dev/null +++ b/hugolib/breaking_changes_test.go @@ -0,0 +1,141 @@ +// 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 hugolib + +import ( + "fmt" + "testing" + + qt "github.com/frankban/quicktest" +) + +func Test073(t *testing.T) { + + asertDisabledTaxonomyAndTerm := func(b *sitesBuilder, taxonomy, term bool) { + b.Assert(b.CheckExists("public/tags/index.html"), qt.Equals, taxonomy) + b.Assert(b.CheckExists("public/tags/tag1/index.html"), qt.Equals, term) + + } + + assertOutputTaxonomyAndTerm := func(b *sitesBuilder, taxonomy, term bool) { + b.Assert(b.CheckExists("public/tags/index.json"), qt.Equals, taxonomy) + b.Assert(b.CheckExists("public/tags/tag1/index.json"), qt.Equals, term) + } + + for _, this := range []struct { + name string + config string + assert func(err error, out string, b *sitesBuilder) + }{ + { + "Outputs for both taxonomy and taxonomyTerm", + `[outputs] + taxonomy = ["JSON"] + taxonomyTerm = ["JSON"] + +`, + func(err error, out string, b *sitesBuilder) { + b.Assert(err, qt.IsNil) + assertOutputTaxonomyAndTerm(b, true, true) + + }, + }, + { + "Outputs for taxonomyTerm", + `[outputs] +taxonomyTerm = ["JSON"] + +`, + func(err error, out string, b *sitesBuilder) { + b.Assert(err, qt.IsNil) + assertOutputTaxonomyAndTerm(b, true, false) + + }, + }, + { + "Outputs for taxonomy only", + `[outputs] +taxonomy = ["JSON"] + +`, + func(err error, out string, b *sitesBuilder) { + b.Assert(err, qt.Not(qt.IsNil)) + b.Assert(out, qt.Contains, `ignoreErrors = ["error-output-taxonomy"]`) + + }, + }, + { + "Outputs for taxonomy only, ignore error", + ` +ignoreErrors = ["error-output-taxonomy"] +[outputs] +taxonomy = ["JSON"] + +`, + func(err error, out string, b *sitesBuilder) { + b.Assert(err, qt.IsNil) + assertOutputTaxonomyAndTerm(b, true, false) + + }, + }, + { + "Disable both taxonomy and taxonomyTerm", + `disableKinds = ["taxonomy", "taxonomyTerm"]`, + func(err error, out string, b *sitesBuilder) { + b.Assert(err, qt.IsNil) + asertDisabledTaxonomyAndTerm(b, false, false) + + }, + }, + { + "Disable only taxonomyTerm", + `disableKinds = ["taxonomyTerm"]`, + func(err error, out string, b *sitesBuilder) { + b.Assert(err, qt.IsNil) + asertDisabledTaxonomyAndTerm(b, false, true) + + }, + }, + { + "Disable only taxonomy", + `disableKinds = ["taxonomy"]`, + func(err error, out string, b *sitesBuilder) { + b.Assert(err, qt.Not(qt.IsNil)) + b.Assert(out, qt.Contains, `ignoreErrors = ["error-disable-taxonomy"]`) + }, + }, + { + "Disable only taxonomy, ignore error", + `disableKinds = ["taxonomy"] + ignoreErrors = ["error-disable-taxonomy"]`, + func(err error, out string, b *sitesBuilder) { + b.Assert(err, qt.IsNil) + asertDisabledTaxonomyAndTerm(b, false, true) + }, + }, + } { + + t.Run(this.name, func(t *testing.T) { + b := newTestSitesBuilder(t).WithConfigFile("toml", this.config) + b.WithTemplatesAdded("_default/list.json", "JSON") + out, err := captureStdout(func() error { + return b.BuildE(BuildCfg{}) + }) + fmt.Println(out) + this.assert(err, out, b) + }) + + } + +} diff --git a/hugolib/cascade_test.go b/hugolib/cascade_test.go index dd3aa72a6..33fc7ceec 100644 --- a/hugolib/cascade_test.go +++ b/hugolib/cascade_test.go @@ -61,13 +61,13 @@ func TestCascade(t *testing.T) { b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` -12|taxonomy|categories/cool/_index.md|Cascade Category|cat.png|categories|HTML-| -12|taxonomy|categories/catsect1|catsect1|cat.png|categories|HTML-| -12|taxonomy|categories/funny|funny|cat.png|categories|HTML-| -12|taxonomyTerm|categories/_index.md|My Categories|cat.png|categories|HTML-| -32|taxonomy|categories/sad/_index.md|Cascade Category|sad.png|categories|HTML-| -42|taxonomy|tags/blue|blue|home.png|tags|HTML-| -42|taxonomyTerm|tags|Cascade Home|home.png|tags|HTML-| +12|term|categories/cool/_index.md|Cascade Category|cat.png|categories|HTML-| +12|term|categories/catsect1|catsect1|cat.png|categories|HTML-| +12|term|categories/funny|funny|cat.png|categories|HTML-| +12|taxonomy|categories/_index.md|My Categories|cat.png|categories|HTML-| +32|term|categories/sad/_index.md|Cascade Category|sad.png|categories|HTML-| +42|term|tags/blue|blue|home.png|tags|HTML-| +42|taxonomy|tags|Cascade Home|home.png|tags|HTML-| 42|section|sectnocontent|Cascade Home|home.png|sectnocontent|HTML-| 42|section|sect3|Cascade Home|home.png|sect3|HTML-| 42|page|bundle1/index.md|Cascade Home|home.png|page|HTML-| @@ -77,7 +77,7 @@ func TestCascade(t *testing.T) { 42|page|sect3/p1.md|Cascade Home|home.png|sect3|HTML-| 42|page|sectnocontent/p1.md|Cascade Home|home.png|sectnocontent|HTML-| 42|section|sectnofrontmatter/_index.md|Cascade Home|home.png|sectnofrontmatter|HTML-| -42|taxonomy|tags/green|green|home.png|tags|HTML-| +42|term|tags/green|green|home.png|tags|HTML-| 42|home|_index.md|Home|home.png|page|HTML-| 42|page|p1.md|p1|home.png|page|HTML-| 42|section|sect1/_index.md|Sect1|sect1.png|stype|HTML-| diff --git a/hugolib/content_map.go b/hugolib/content_map.go index 8af553478..43ad7745d 100644 --- a/hugolib/content_map.go +++ b/hugolib/content_map.go @@ -274,13 +274,13 @@ type contentBundleViewInfo struct { func (c *contentBundleViewInfo) kind() string { if c.termKey != "" { - return page.KindTaxonomy + return page.KindTerm } - return page.KindTaxonomyTerm + return page.KindTaxonomy } func (c *contentBundleViewInfo) sections() []string { - if c.kind() == page.KindTaxonomyTerm { + if c.kind() == page.KindTaxonomy { return []string{c.name.plural} } diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index b5165b2a5..b32f808c9 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -106,7 +106,7 @@ func (m *pageMap) newPageFromContentNode(n *contentNode, parentBucket *pagesMapB sections := s.sectionsFromFile(f) kind := s.kindFromFileInfoOrSections(f, sections) - if kind == page.KindTaxonomy { + if kind == page.KindTerm { s.PathSpec.MakePathsSanitized(sections) } @@ -535,7 +535,7 @@ func (m *pageMap) assembleTaxonomies() error { } } else { title := "" - if kind == page.KindTaxonomy { + if kind == page.KindTerm { title = n.viewInfo.term() } n.p = m.s.newPage(n, parent.p.bucket, kind, title, sections...) diff --git a/hugolib/content_map_test.go b/hugolib/content_map_test.go index 9ec30201a..42a69c26b 100644 --- a/hugolib/content_map_test.go +++ b/hugolib/content_map_test.go @@ -451,8 +451,8 @@ Draft5: {{ if (.Site.GetPage "blog/draftsection/sub/page") }}FOUND{{ end }}| Pages: /blog/page3/|/blog/subsection/|/blog/page2/|/blog/page1/|/blog/bundle/| Sections: /blog/|/docs/| Categories: /categories/funny/; funny; 11| - Category Terms: taxonomyTerm: /categories/funny/; funny; 11| - Category Funny: taxonomy; funny: /blog/subsection/page4/;|/blog/page3/;|/blog/subsection/;|/blog/page2/;|/blog/page1/;|/blog/subsection/page5/;|/docs/page6/;|/blog/bundle/;|;| + Category Terms: taxonomy: /categories/funny/; funny; 11| + Category Funny: term; funny: /blog/subsection/page4/;|/blog/page3/;|/blog/subsection/;|/blog/page2/;|/blog/page1/;|/blog/subsection/page5/;|/docs/page6/;|/blog/bundle/;|;| Pag Num Pages: 7 Pag Blog Num Pages: 4 Blog Num RegularPages: 4 diff --git a/hugolib/disableKinds_test.go b/hugolib/disableKinds_test.go index 87c2b5d3d..4f12ee2b5 100644 --- a/hugolib/disableKinds_test.go +++ b/hugolib/disableKinds_test.go @@ -28,6 +28,7 @@ func TestDisable(t *testing.T) { config := fmt.Sprintf(` baseURL = "http://example.com/blog" enableRobotsTXT = true +ignoreErrors = ["error-disable-taxonomy"] disableKinds = [%q] `, disableKind) @@ -141,7 +142,7 @@ title: Headless Local Lists Sub b.Assert(len(s.Taxonomies()["categories"]), qt.Equals, 0) }) - disableKind = page.KindTaxonomy + disableKind = page.KindTerm c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) @@ -153,7 +154,7 @@ title: Headless Local Lists Sub b.Assert(getPage(b, "/categories/mycat"), qt.IsNil) }) - disableKind = page.KindTaxonomyTerm + disableKind = page.KindTaxonomy c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) @@ -319,7 +320,7 @@ title: Headless Local Lists Sub // https://github.com/gohugoio/hugo/issues/6897#issuecomment-587947078 func TestDisableRSSWithRSSInCustomOutputs(t *testing.T) { b := newTestSitesBuilder(t).WithConfigFile("toml", ` -disableKinds = ["taxonomy", "taxonomyTerm", "RSS"] +disableKinds = ["term", "taxonomy", "RSS"] [outputs] home = [ "HTML", "RSS" ] `).Build(BuildCfg{}) diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go index 16de27b0d..e71e48d41 100644 --- a/hugolib/hugo_sites.go +++ b/hugolib/hugo_sites.go @@ -443,8 +443,8 @@ func applyDeps(cfg deps.DepsCfg, sites ...*Site) error { contentMap: newContentMap(contentMapConfig{ lang: s.Lang(), taxonomyConfig: s.siteCfg.taxonomiesConfig.Values(), - taxonomyDisabled: !s.isEnabled(page.KindTaxonomy), - taxonomyTermDisabled: !s.isEnabled(page.KindTaxonomyTerm), + taxonomyDisabled: !s.isEnabled(page.KindTerm), + taxonomyTermDisabled: !s.isEnabled(page.KindTaxonomy), pageDisabled: !s.isEnabled(page.KindPage), }), s: s, @@ -493,6 +493,9 @@ func applyDeps(cfg deps.DepsCfg, sites ...*Site) error { // NewHugoSites creates HugoSites from the given config. func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error) { + if cfg.Logger == nil { + cfg.Logger = loggers.NewErrorLogger() + } sites, err := createSitesFromConfig(cfg) if err != nil { return nil, errors.Wrap(err, "from config") diff --git a/hugolib/hugo_sites_build_test.go b/hugolib/hugo_sites_build_test.go index 59f228fef..84655c1f2 100644 --- a/hugolib/hugo_sites_build_test.go +++ b/hugolib/hugo_sites_build_test.go @@ -339,14 +339,14 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) { nnSite := sites[2] c.Assert(nnSite.language.Lang, qt.Equals, "nn") - taxNn := nnSite.getPage(page.KindTaxonomyTerm, "lag") + taxNn := nnSite.getPage(page.KindTaxonomy, "lag") c.Assert(taxNn, qt.Not(qt.IsNil)) c.Assert(len(taxNn.Translations()), qt.Equals, 1) c.Assert(taxNn.Translations()[0].Language().Lang, qt.Equals, "nb") - taxTermNn := nnSite.getPage(page.KindTaxonomy, "lag", "sogndal") + taxTermNn := nnSite.getPage(page.KindTerm, "lag", "sogndal") c.Assert(taxTermNn, qt.Not(qt.IsNil)) - c.Assert(nnSite.getPage(page.KindTaxonomy, "LAG", "SOGNDAL"), qt.Equals, taxTermNn) + c.Assert(nnSite.getPage(page.KindTerm, "LAG", "SOGNDAL"), qt.Equals, taxTermNn) c.Assert(len(taxTermNn.Translations()), qt.Equals, 1) c.Assert(taxTermNn.Translations()[0].Language().Lang, qt.Equals, "nb") diff --git a/hugolib/hugo_smoke_test.go b/hugolib/hugo_smoke_test.go index 406255d51..5aa508290 100644 --- a/hugolib/hugo_smoke_test.go +++ b/hugolib/hugo_smoke_test.go @@ -27,7 +27,7 @@ func TestHello(t *testing.T) { b := newTestSitesBuilder(t) b.WithConfigFile("toml", ` baseURL="https://example.org" -disableKinds = ["taxonomy", "taxonomyTerm", "section", "page"] +disableKinds = ["term", "taxonomy", "section", "page"] `) b.WithContent("p1", ` --- diff --git a/hugolib/page.go b/hugolib/page.go index baf5e7f69..28ef1e156 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -212,9 +212,9 @@ func (p *pageState) RegularPages() page.Pages { switch p.Kind() { case page.KindPage: - case page.KindSection, page.KindHome, page.KindTaxonomyTerm: + case page.KindSection, page.KindHome, page.KindTaxonomy: pages = p.getPages() - case page.KindTaxonomy: + case page.KindTerm: all := p.Pages() for _, p := range all { if p.IsPage() { @@ -240,9 +240,9 @@ func (p *pageState) Pages() page.Pages { case page.KindPage: case page.KindSection, page.KindHome: pages = p.getPagesAndSections() - case page.KindTaxonomy: + case page.KindTerm: pages = p.bucket.getTaxonomyEntries() - case page.KindTaxonomyTerm: + case page.KindTaxonomy: pages = p.bucket.getTaxonomies() default: pages = p.s.Pages() @@ -436,7 +436,7 @@ func (p *pageState) getLayoutDescriptor() output.LayoutDescriptor { if len(sections) > 0 { section = sections[0] } - case page.KindTaxonomyTerm, page.KindTaxonomy: + case page.KindTaxonomy, page.KindTerm: b := p.getTreeRef().n section = b.viewInfo.name.singular default: diff --git a/hugolib/page__data.go b/hugolib/page__data.go index 131bf8d5d..9fc97f8f6 100644 --- a/hugolib/page__data.go +++ b/hugolib/page__data.go @@ -35,7 +35,7 @@ func (p *pageData) Data() interface{} { } switch p.Kind() { - case page.KindTaxonomy: + case page.KindTerm: b := p.treeRef.n name := b.viewInfo.name termKey := b.viewInfo.termKey @@ -46,7 +46,7 @@ func (p *pageData) Data() interface{} { p.data["Singular"] = name.singular p.data["Plural"] = name.plural p.data["Term"] = b.viewInfo.term() - case page.KindTaxonomyTerm: + case page.KindTaxonomy: b := p.treeRef.n name := b.viewInfo.name diff --git a/hugolib/page__meta.go b/hugolib/page__meta.go index 435b95473..c7226c6f2 100644 --- a/hugolib/page__meta.go +++ b/hugolib/page__meta.go @@ -52,7 +52,7 @@ type pageMeta struct { // in the different page collections. This can, as an example, be used // to to filter regular pages, find sections etc. // Kind will, for the pages available to the templates, be one of: - // page, home, section, taxonomy and taxonomyTerm. + // page, home, section, taxonomy and term. // It is of string type to make it easy to reason about in // the templates. kind string @@ -678,11 +678,11 @@ func (p *pageMeta) applyDefaultValues(n *contentNode) error { } else { p.title = sectionName } - case page.KindTaxonomy: + case page.KindTerm: // TODO(bep) improve key := p.sections[len(p.sections)-1] p.title = strings.Replace(p.s.titleFunc(key), "-", " ", -1) - case page.KindTaxonomyTerm: + case page.KindTaxonomy: p.title = p.s.titleFunc(p.sections[0]) case kind404: p.title = "404 Page not found" diff --git a/hugolib/page__paginator.go b/hugolib/page__paginator.go index 942597e04..5948735d1 100644 --- a/hugolib/page__paginator.go +++ b/hugolib/page__paginator.go @@ -89,7 +89,7 @@ func (p *pagePaginator) Paginator(options ...interface{}) (*page.Pager, error) { // section. To avoid the default paginators for the home page // changing in the wild, we make this a special case. pages = p.source.s.RegularPages() - case page.KindTaxonomy, page.KindTaxonomyTerm: + case page.KindTerm, page.KindTaxonomy: pages = p.source.Pages() default: pages = p.source.RegularPages() diff --git a/hugolib/page__paths.go b/hugolib/page__paths.go index 5dc42bc2a..d0bf26961 100644 --- a/hugolib/page__paths.go +++ b/hugolib/page__paths.go @@ -147,7 +147,7 @@ func createTargetPathDescriptor(s *Site, p page.Page, pm *pageMeta) (page.Target // the permalink configuration values are likely to be redundant, e.g. // naively expanding /category/:slug/ would give /category/categories/ for // the "categories" page.KindTaxonomyTerm. - if p.Kind() == page.KindPage || p.Kind() == page.KindTaxonomy { + if p.Kind() == page.KindPage || p.Kind() == page.KindTerm { opath, err := d.ResourceSpec.Permalinks.Expand(p.Section(), p) if err != nil { return desc, err diff --git a/hugolib/page__tree.go b/hugolib/page__tree.go index d2ef00e76..a617ad384 100644 --- a/hugolib/page__tree.go +++ b/hugolib/page__tree.go @@ -171,7 +171,7 @@ func (pt pageTree) Parent() page.Page { tree := p.getTreeRef() - if tree == nil || pt.p.Kind() == page.KindTaxonomyTerm { + if tree == nil || pt.p.Kind() == page.KindTaxonomy { return pt.p.s.home } diff --git a/hugolib/page_kinds.go b/hugolib/page_kinds.go index 4f000c3e5..683d12c1b 100644 --- a/hugolib/page_kinds.go +++ b/hugolib/page_kinds.go @@ -22,7 +22,7 @@ import ( var ( // This is all the kinds we can expect to find in .Site.Pages. - allKindsInPages = []string{page.KindPage, page.KindHome, page.KindSection, page.KindTaxonomy, page.KindTaxonomyTerm} + allKindsInPages = []string{page.KindPage, page.KindHome, page.KindSection, page.KindTerm, page.KindTaxonomy} ) const ( diff --git a/hugolib/pagebundler_test.go b/hugolib/pagebundler_test.go index 4566c5f97..fa420a025 100644 --- a/hugolib/pagebundler_test.go +++ b/hugolib/pagebundler_test.go @@ -1145,7 +1145,7 @@ func TestPageBundlerPartialTranslations(t *testing.T) { baseURL = "https://example.org" defaultContentLanguage = "en" defaultContentLanguageInSubDir = true -disableKinds = ["taxonomyTerm", "taxonomy"] +disableKinds = ["taxonomy", "term"] [languages] [languages.nn] languageName = "Nynorsk" diff --git a/hugolib/pagecollections_test.go b/hugolib/pagecollections_test.go index bb846da85..b9623eb34 100644 --- a/hugolib/pagecollections_test.go +++ b/hugolib/pagecollections_test.go @@ -279,8 +279,8 @@ func TestGetPage(t *testing.T) { {"Abs, ignore context, page deep", "NoPage", sec3, []string{"/subsect/deep.md"}, ""}, // Taxonomies - {"Taxonomy term", page.KindTaxonomyTerm, nil, []string{"categories"}, "Categories"}, - {"Taxonomy", page.KindTaxonomy, nil, []string{"categories/hugo", "categories/Hugo"}, "Hugo"}, + {"Taxonomy term", page.KindTaxonomy, nil, []string{"categories"}, "Categories"}, + {"Taxonomy", page.KindTerm, nil, []string{"categories/hugo", "categories/Hugo"}, "Hugo"}, // Bundle variants {"Bundle regular", page.KindPage, nil, []string{"sect3/b1", "sect3/b1/index.md", "sect3/b1/index.en.md"}, "b1 bundle"}, diff --git a/hugolib/resource_chain_babel_test.go b/hugolib/resource_chain_babel_test.go index c9ddb2140..d3351dfd4 100644 --- a/hugolib/resource_chain_babel_test.go +++ b/hugolib/resource_chain_babel_test.go @@ -82,7 +82,7 @@ class Car { v := viper.New() v.Set("workingDir", workDir) - v.Set("disableKinds", []string{"taxonomyTerm", "taxonomy", "page"}) + v.Set("disableKinds", []string{"taxonomy", "term", "page"}) b := newTestSitesBuilder(t).WithLogger(loggers.NewWarningLogger()) // Need to use OS fs for this. diff --git a/hugolib/resource_chain_test.go b/hugolib/resource_chain_test.go index 67641bdb8..c687ca342 100644 --- a/hugolib/resource_chain_test.go +++ b/hugolib/resource_chain_test.go @@ -895,7 +895,7 @@ h1 { newTestBuilder := func(v *viper.Viper) *sitesBuilder { v.Set("workingDir", workDir) - v.Set("disableKinds", []string{"taxonomyTerm", "taxonomy", "page"}) + v.Set("disableKinds", []string{"taxonomy", "term", "page"}) b := newTestSitesBuilder(t).WithLogger(loggers.NewWarningLogger()) // Need to use OS fs for this. b.Fs = hugofs.NewDefault(v) diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go index 8bb468465..961450cb8 100644 --- a/hugolib/shortcode_test.go +++ b/hugolib/shortcode_test.go @@ -626,7 +626,7 @@ baseURL = "http://example.com/blog" paginate = 1 -disableKinds = ["section", "taxonomy", "taxonomyTerm", "RSS", "sitemap", "robotsTXT", "404"] +disableKinds = ["section", "term", "taxonomy", "RSS", "sitemap", "robotsTXT", "404"] [outputs] home = [ "HTML", "AMP", "Calendar" ] diff --git a/hugolib/site.go b/hugolib/site.go index a0390780a..5507d7a78 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -28,6 +28,10 @@ import ( "strings" "time" + "github.com/gohugoio/hugo/common/constants" + + "github.com/gohugoio/hugo/common/loggers" + "github.com/gohugoio/hugo/resources" "github.com/gohugoio/hugo/identity" @@ -397,12 +401,34 @@ func newSite(cfg deps.DepsCfg) (*Site, error) { if cfg.Language == nil { cfg.Language = langs.NewDefaultLanguage(cfg.Cfg) } + if cfg.Logger == nil { + panic("logger must be set") + } + + ignoreErrors := cast.ToStringSlice(cfg.Language.Get("ignoreErrors")) + ignorableLogger := loggers.NewIgnorableLogger(cfg.Logger, ignoreErrors...) disabledKinds : |