How to include the "next" partial in the search path?

I’m trying to extend an existing theme slightly, but I can’t quite figure out how to do it. Specifically, I’d like to add some extra scripts to every page. Currently, the hyde-y theme has a few scripts pulled into every page like this:

I can override this with my own layouts/partials/base/scripts file, but then I lose the scripts from the hyde-y theme. I tried putting a {{ partial "base/scripts" . }} in my scripts file, assuming it’d go to the next in the search path, but that seems to instead recurse until the stack overflows and hugo crashes. What I think I need is something like {{ include_next }} at the end of my scripts, but it doesn’t look like such a thing exists?

The other approach I came up with would be to author my own layouts/partials/foot.html which is a copy of that file, but includes my own scripts partial in addition to they hyde-y theme’s partial, but that feels wrong because if the hyde-y theme updates its footer, then I’ll miss those changes.

New to Hugo, so possibly I’m architecting this incorrectly, but I couldn’t find any docs on idiomatic ways to extend themes.

Having your own layouts/partials/base/scripts.html overwrites the same file in the theme, so calling {{ partial "base/scripts" . }} from inside it, is in effect calling itself, hence the crash.

You could add the contents of the theme scripts file back into your own scripts file, or overwrite the footer.

But for both of these options, if the upstream theme updates, then I need to manually check and copy over every file that I’ve copied / overwritten, right? Is there a mechanism in Hugo to extend a theme rather than overwrite it?

Hugo has a lot of features that extend a theme, but what you are talking about are templates and lookup order. Hugo is made in a way that allows theme author’s to include empty partials where a site publisher can include their own overrides without conflicting with the theme.

In fact, that theme has one, called foot-extra.html. Put your scripts in your own foot-extra.html, it should work out. :slight_smile:

Right in front my face the whole time. Thanks for your help!