Theme render-hook override: how to fall back to Hugo default?

If a theme defines a render hook, is there an easy way for a project (using that theme) to “opt out” of the theme’s render hook?

I’m not aware of an easy way, but figured that I’d ask. The only way I can think of, is for the project itself to override the theme’s hook. But I don’t want projects to have to do that unless they can simply reference, say, a Hugo-internal hook template wholesale. Maybe there’s an even simpler way?

Question context: the Docsy theme recently started using a heading render hook to generate heading self links, but it occurred to me that this might be a problem for projects: if projects can’t easily opt out, then Docsy will have to make this feature opt-in.


1 Like

No, you can’t “opt out”. The “easy way” you are thinking about is probably putting your own render hook into /layouts/_default/... and that is the proper way to override the theme’s renderhook.

The content would be something like this:

<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }}</h{{ .Level }}>