Skip to content

Template selection considers last media type suffix (alphabetically) instead of first (by slice order) #13877

@jmooring

Description

@jmooring

This is not a recent regression; the behavior exists in v0.146.0 and later.

While updating the docs for the new template selection logic, I ran across this:

Note that if the output format’s Media Type has more than one suffix defined, only the first is considered.

I wanted to verify that the behavior had not changed, and found that with v0.146.0 and later, only the last (sorted alphabetically) is considered.

site config

[mediaTypes.'text/html']
suffixes = ['b','a','d','c']

[outputFormats.html]
mediaType = 'text/html'

project structure

./
├── content/
│   └── p1.md
├── layouts/
│   └── _default/
│       ├── page.html.a
│       ├── page.html.b
│       ├── page.html.c
│       └── page.html.d
└── hugo.toml

With the example above, layouts/_default/page.html.d is used instead of layouts/_default/page.html.b. However, the page is published to the correct path:

public/
└── p1/
    └── index.b  <-- extension is correct, but wrong template is used

This example is obviously contrived, and I suspect a rare configuration/setup.

Test case to follow.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions