Hi, I was thinking this update (0.146) was just the right time to simplify the structure of my hugo site and reduce redundant templates.
I got the feeling I had understood the new simpler lookup order but it turns out in practice some things are not quite working as I imagine. (It didn’t help that ChatGPT gave the typical very confident but false answers, either
So what I’m asking is: shouldn’t the partials also follow some lookup logic akin to layouts?
hugo correctly selects home.html from /splash but uses /partials/featured.html instead of featured.splash.html which I thought the above quote was saying.
I also tried to be more specific with {{ partial "featured.splash" . }} and {{ partial "featured.splash.html" . }} but no change… and at that point I changed it back to featured-splash.html which defeats the whole point.
Unlike other template types, partial template selection is based on the file name passed in the partial call. Hugo does not consider the current page kind, content type, logical path, language, or output format when searching for a matching partial template.
Unlike other template types, partial template selection is based on the file name passed in the partial call. Hugo does not consider the current page kind, content type, logical path, language, or output format when searching for a matching partial template.
I just want to say, regardless the technical feasibility, if the logic from template types#partial would work with “types” (and not just .section and .de like mentioned there) this would minimize some of the lower level templates (i.e. home, single,…) and even some other partials (you can call partials out of partials, right?) would be redundant in my projects.
But I’m still just beginning to grasp the full power of hugo.
partial template selection is based on the file name passed
as I said, I never tried this way of selecting some partials… just folder structure - and at least to me the docs here are not as precise as on other places …
If the bar and oops output formats have not been defined, Hugo ignores the output format designator, and layouts/_partials/foo.html will be used for all three.
I’m sorry you find this documentation insufficient:
Unlike other template types, partial template selection is based on the file name passed in the partial call. Hugo does not consider the current page kind, content type, logical path, language, or output format when searching for a matching partial template. However, Hugo does apply the same name matching logic it uses for other templates. This means it tries to find the most specific match first, then progressively looks for more general versions if the specific one isn’t found.
Perhaps someone with a better command of the English language can make a suggestion.
so definitely not me. I’ll read the whole page two more times with your explanations i may get it
partial template selection is based on the file name passed
Hugo does not consider the current …
find the most specific
lead me to partial filename is just a name and not contains semantic stuff like kind, output format…
starting with this
adding background from lookup order (standard template naming rules) and your explanation in this issue e.g. “output formats have not been defined” and ofc some forum topics…