Add slice-based permalinks config with PageMatcher target

Closes #14744
Clses #4641

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bjørn Erik Pedersen
2026-04-15 23:38:25 +02:00
parent e3413d927f
commit 017a7cd63a
9 changed files with 526 additions and 161 deletions
+8 -7
View File
@@ -181,7 +181,7 @@ type Config struct {
Minify minifiers.MinifyConfig `mapstructure:"-"`
// Permalink configuration.
Permalinks map[string]map[string]string `mapstructure:"-"`
Permalinks page.PermalinksConfig `mapstructure:"-"`
// Taxonomy configuration.
Taxonomies map[string]string `mapstructure:"-"`
@@ -479,12 +479,13 @@ func (c *Config) CompileConfig(logger loggers.Logger) error {
}
// Legacy permalink tokens
vs := fmt.Sprintf("%v", c.Permalinks)
if strings.Contains(vs, ":filename") {
hugo.DeprecateWithLogger("the \":filename\" permalink token", "Use \":contentbasename\" instead.", "0.144.0", logger.Logger())
}
if strings.Contains(vs, ":slugorfilename") {
hugo.DeprecateWithLogger("the \":slugorfilename\" permalink token", "Use \":slugorcontentbasename\" instead.", "0.144.0", logger.Logger())
for _, pc := range c.Permalinks {
if strings.Contains(pc.Pattern, ":filename") {
hugo.DeprecateWithLogger("the \":filename\" permalink token", "Use \":contentbasename\" instead.", "0.144.0", logger.Logger())
}
if strings.Contains(pc.Pattern, ":slugorfilename") {
hugo.DeprecateWithLogger("the \":slugorfilename\" permalink token", "Use \":slugorcontentbasename\" instead.", "0.144.0", logger.Logger())
}
}
// Legacy render hook values.
+2 -1
View File
@@ -307,9 +307,10 @@ var allDecoderSetups = map[string]decodeWeight{
key: "permalinks",
decode: func(d decodeWeight, p decodeConfig) error {
var err error
p.c.Permalinks, err = page.DecodePermalinksConfig(p.p.GetStringMap(d.key))
p.c.Permalinks, err = page.DecodePermalinksConfig(p.p.Get(d.key))
return err
},
getInitializer: func(c *Config) configInitializer { return c.Permalinks },
},
"sitemap": {
key: "sitemap",