Cannot override {{define "breadcrumbs"}} in Hugo Learn Theme

I use

First, I’m not sure about the exact purpose of the define keyword. All I can find is

I try to override themes/hugo-theme-learn/layouts/partials/header.html with a modified version in layouts/partials/header.html.

Modifying the breadcrumb template (or block?) in the {{define "breadcrumb"}} ... {{ end }} has no effect. Somehow the breadcrumb (template?/block?) defined in themes/hugo-theme-learn/layouts/partials/header.html is still in use.

If I change the name from breadcrumb to breadcrumb2 in layouts/partials/header.html it works. Is this the expected behaviour of the Hugo templating system and if so, where can I learn more?

I’ve filed an issue in the theme repo but I think this is probably not specific to the Hugo Learn Theme and therefore also post here.



First note that the “define” in a partial is conceptually different than the block thing (but they are related on the implementation level).

Your expectation is in line with mine, but I will admit I have not tested this myself.

I have a nagging suspicion about what’s happening here: I suspect the templates defined inline in the partials are put into the same namespace as the rest of the templates, and hence the “last one will win”.

If that is so, we could probably work around it for the theme vs regular use case, but there are still some gotchas here; and if this is the case, it sounds like a very surprising implementation from the Go project. But I will check.

I have created this issue to track it:


Thanks @bep!

All I can find about define is

Where can I read more about the difference between define when overriding a block and define in Hugo partials?

In the Hugo documentation about base templates; but it isn’t really relevant to this discussion so please don’t ask me to go look for the URL.

1 Like

Before posting I looked at but since in my setting there was no blocks defined inside any of the files inside /layouts/_default/ I was (and still is) not sure what it means to use {{ define <name> }} when there is no {{ block <name> }} defined. But you are probably right, it is not relevant to the underlying issue :slight_smile:

I’m trying to revise the breadcrumb macro so that the last element (the page itself) is also linked for a taxonomy page, but I can’t seem to get it to work. I’d appreciate an assist if someone could help.