Reference theme partial from site partial with the same name

I’m using a theme that uses a partial called single-post-info.html. This partial is referenced in the theme’s single.html.

On my site I would like to add one line to single-post-info.html. This is specific to my site so it doesn’t warrant a change to the theme. I would, however, like to keep receiving updates to the theme. I also don’t want to make a site-specific single.html that references my own partial. I guess I’d call what I’m looking for some sort of partial “inheritance”.

I tried

{{ partial "single-post-info.html" . }}

inside my custom single-post-info.html but that just sends Hugo into an endless loop and an eventual stack overflow. I was hoping that, since I’m inside a partial, Hugo would start searching higher up the hierarchy, but unfortunately it looks like that’s not the case.

My question:

Is it possible to redefine a partial in my layouts/partials/single-post-info.html that references themes/<THEME>/layouts/partials/single-post-info.html? Or do I need to copy the entire contents of the partial from the theme into my own partial and add my single line?

The Hugo documentation says:

This allows a theme’s end user to copy a partial’s contents into a file of the same name for further customization.

so I’m afraid what I want is not possible, but I thought I’d give it a shot anyway.

I also created a Gist for additional clarification:

Yep, copy and add your single line.

That particular partial isn’t too big, and will likely be notable if it changes (as in being noted in the changelog). If it were a larger or more complex partial I’d ask the theme author to put a partial in where I needed a change. I think single-post-info is where that theme author intended you to make your changes. :slight_smile:

1 Like

That’s what I was afraid of. I’ll copy the content of the partial then. Thanks for your help! :slight_smile: