I created a theme that uses a single block template:
./themes/mytheme/layouts/_default/baseof.html. This is basically the site envelope, almost verbatim from the docs.
This is working fine, but now I need to override this site envelope. So I copied
./layouts/_default/baseof.html. But it’s not being seen at all.
For a test, i renamed my template’s
baseof.html to something else, and the site broke (generated
index.html is blank). also for a test, i created a
list.html, and that works fine.
Am I missing something? are block templates only supported within a theme?
No, I use block templates in non-theme sites, so I suspect you must doing something wrong. Do you have a “broken” example we can look at? (the source, GitHub link?)
sure thing - here’s a repro case.
baseof.html in the theme and in the overlay are identical. just rename or delete
baseof.html in the theme, and you’ll see it break.
(I’m on Hugo 0.18-DEV)
(Edit: advance apologies if i’m being completely dense and missing something very obvious)
I see a
baseof.html but no other template – that does not work.
I see how you think – and we should probably support that, but currently baseof + the real template comes in pairs, we don’t pick one in the theme and the other in the project.
You should describe this in a GitHub issue, maybe someone will add that support.
Ah, ok. that explains it. thanks. Yes, my thinking was that the
baseof.html in the project would override the one in the theme, with everything else remaining in the theme.
so just to confirm my understanding: to use an overriding block template that uses a
main block, I would need to provide a
baseof.html in my project, as well as all other templates that define the
main block? E.g.: I copied
index.html from the theme’s
layouts to the project, and the
/ page works. but no other pages. If i then copy a
list template, the list pages start working.
Is this correct?
If so, this isn’t very maintainable and significantly degrades the usefulness of block templates, so i’m definitely going to open a GH issue.
You are right about that – I see that, but I haven’t thought about it (I haven’t had that problem, so to say)
totally understandable! thank you for the help!
This tripped me up too.
I’m using the Ananke theme (https://themes.gohugo.io/gohugo-theme-ananke/). Replacing the baseof.html seems to be the only reasonable way to do things like customise the theme’s style. The docs imply in a few places that I just need to replace the baseof.html file, not every other template file as well.
By the time so much of the theme is replaced it’s questionable whether retaining the original theme files would be worthwhile, as I have to juggle two different similar-but-different folders. I’m starting to wonder if it’s better to fork the theme and just override whatever I need, or to copy the entire theme into my root directory and then customise as I please.