Hey folks!
Intro
So I’m having a templating problem. I’m not sure if this is a regression with the new system, a docs issue, or if I’m simply misunderstanding. This issue exists in a new theme I’m creating for my Linodians website. The repo is here. The branch, linked, is classic-theme and the theme I’m working on is linodians-classic. I will include snippets below.
The Problem
So in my theme I am using a partial for the header. That partial is located at _partials/header.html. What I want to happen is, that partial is used unless a more specific partial exists. I have a section called jsonfeed and when pages from that section are rendered, I want to use the partial _partials/header.jsonfeed.html. Despite this, only _partials/header.html is being used.
In short, I want to do the same general thing that the person in this closed topic wanted to do. In that topic, they were told it doesn’t work that way, to use renders. The problem is, in this doc it is suggested that it does work that way. Here’s the relevant snippet:
Hugo uses this lookup order to find a matching template:
layouts/_partials/footer.section.de.html layouts/_partials/footer.section.html layouts/_partials/footer.de.html layouts/_partials/footer.html
So is @jmooring (
) right and the doc is wrong? Vice-versa? I’m assuming he’s correct as I haven’t gotten this to work yet.
Extra Information
If you don’t want to dig into the repo (linked above), here’s snippets of what I’m doing.
ls -lah src/themes/linodians-classic/layouts/_partials/
header.html
header.jsonfeed.html
header.section.html
The last file was me just throwing things against the wall to see what sticks. ![]()
From my base template, layouts/baseof.html I have this snippet calling the partial:
27 {{ $headerTpl := "header" }}
28 {{ with .Section }}{{ $headerTpl = printf "%s.%s.html" $headerTpl . }}{{ end }}
29 <p>DEBUG: {{ $headerTpl }}</p>
30 {{ partial $headerTpl . -}}
The debug paragraph I have there shows me that the correct partial string is being generated on each page. Despite that, only the bare header partial is being displayed. To make sure I know what actual partial is being used when pages are rendered, I’ve put some debugging words in front of the site title in the header for each partial.
It’s late for me so I’ll head to bed. In the morning I’ll try to do this with renders instead but I still think something (code or docs) is off here.
Hugo version string: hugo v0.152.2-6abdacad3f3fe944ea42177844469139e81feda6+extended linux/arm64 BuildDate=2025-10-24T15:31:49Z VendorInfo=snap:0.152.2
