}
func (sa *sitePagesAssembler) assembleTermsAndTranslations() error {
+ if sa.pageMap.cfg.taxonomyTermDisabled {
+ return nil
+ }
+
var (
pages = sa.pageMap.treePages
entries = sa.pageMap.treeTaxonomyEntries
return false, nil
}
- if sa.pageMap.cfg.taxonomyTermDisabled {
- return false, nil
- }
-
for _, viewName := range views {
vals := types.ToStringSlicePreserveString(getParam(ps, viewName.plural, false))
if vals == nil {
})
}
}
+
return false, nil
},
}
import (
"fmt"
+ "strings"
"sync"
"sync/atomic"
}
}
+ var tc viewName
// Identify Page Kind.
if m.pageConfig.Kind == "" {
m.pageConfig.Kind = kinds.KindSection
m.pageConfig.Kind = kinds.KindHome
} else if m.pathInfo.IsBranchBundle() {
// A section, taxonomy or term.
- tc := m.s.pageMap.cfg.getTaxonomyConfig(m.Path())
+ tc = m.s.pageMap.cfg.getTaxonomyConfig(m.Path())
if !tc.IsZero() {
// Either a taxonomy or a term.
if tc.pluralTreeKey == m.Path() {
m.pageConfig.Kind = kinds.KindTaxonomy
- m.singular = tc.singular
} else {
m.pageConfig.Kind = kinds.KindTerm
- m.term = m.pathInfo.Unnormalized().BaseNameNoIdentifier()
- m.singular = tc.singular
}
}
} else if m.f != nil {
}
}
+ if m.pageConfig.Kind == kinds.KindTerm || m.pageConfig.Kind == kinds.KindTaxonomy {
+ if tc.IsZero() {
+ tc = m.s.pageMap.cfg.getTaxonomyConfig(m.Path())
+ }
+ if tc.IsZero() {
+ return nil, fmt.Errorf("no taxonomy configuration found for %q", m.Path())
+ }
+ m.singular = tc.singular
+ if m.pageConfig.Kind == kinds.KindTerm {
+ m.term = paths.TrimLeading(strings.TrimPrefix(m.pathInfo.Unnormalized().Base(), tc.pluralTreeKey))
+ }
+ }
+
if m.pageConfig.Kind == kinds.KindPage && !m.s.conf.IsKindEnabled(m.pageConfig.Kind) {
return nil, nil
}
"<p>aaa</p>|content: <p>aaa</p>\n<p>bbb</p>",
)
}
+
+// Issue 13063.
+func TestPagesFromGoTmplTermIsEmpty(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+disableKinds = ['section', 'home', 'rss','sitemap']
+printPathWarnings = true
+[taxonomies]
+tag = "tags"
+-- content/mypost.md --
+---
+title: "My Post"
+tags: ["mytag"]
+---
+-- content/tags/_content.gotmpl --
+{{ .AddPage (dict "path" "mothertag" "title" "My title" "kind" "term") }}
+--
+-- layouts/_default/taxonomy.html --
+Terms: {{ range .Data.Terms.ByCount }}{{ .Name }}: {{ .Count }}|{{ end }}§s
+-- layouts/_default/single.html --
+Single.
+`
+
+ b := hugolib.Test(t, files, hugolib.TestOptWarn())
+
+ b.AssertFileContent("public/tags/index.html", "Terms: mytag: 1|§s")
+}