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

**URL:** <https://discourse.gohugo.io/t/how-to-include-the-next-partial-in-the-search-path/12680>\
**Category:** support\
**Created:** [June 30, 2018, 8:30am UTC](https://discourse.gohugo.io/t/how-to-include-the-next-partial-in-the-search-path/12680 "2018-06-30T08:30:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppannuto](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ppannuto/32/6283_2.png) [@ppannuto](https://discourse.gohugo.io/u/ppannuto)\
**Post date:** [June 30, 2018, 8:30am UTC](https://discourse.gohugo.io/t/how-to-include-the-next-partial-in-the-search-path/12680/1 "2018-06-30T08:30:44Z")

</div>

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: [https://github.com/enten/hyde-y/blob/master/layouts/partials/foot.html#L3](https://github.com/enten/hyde-y/blob/master/layouts/partials/foot.html#L3)

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.

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [June 30, 2018, 8:51am UTC](https://discourse.gohugo.io/t/how-to-include-the-next-partial-in-the-search-path/12680/2 "2018-06-30T08:51:11Z")

</div>

> [@ppannuto](#):
>
> 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.

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.

---

<div class="post-metadata">

**Author:** ![ppannuto](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ppannuto/32/6283_2.png) [@ppannuto](https://discourse.gohugo.io/u/ppannuto)\
**Post date:** [June 30, 2018, 8:56am UTC](https://discourse.gohugo.io/t/how-to-include-the-next-partial-in-the-search-path/12680/3 "2018-06-30T08:56:55Z")

</div>

> [@pointyfar](#):
>
> 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?

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [June 30, 2018, 9:35pm UTC](https://discourse.gohugo.io/t/how-to-include-the-next-partial-in-the-search-path/12680/4 "2018-06-30T21:35:08Z")

</div>

> [@ppannuto](#):
>
> 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`](https://github.com/enten/hyde-y/blob/master/layouts/partials/foot-extra.html). Put your scripts in your own `foot-extra.html`, it should work out. 🙂

---

<div class="post-metadata">

**Author:** ![ppannuto](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ppannuto/32/6283_2.png) [@ppannuto](https://discourse.gohugo.io/u/ppannuto)\
**Post date:** [June 30, 2018, 9:41pm UTC](https://discourse.gohugo.io/t/how-to-include-the-next-partial-in-the-search-path/12680/5 "2018-06-30T21:41:30Z")

</div>

> [@maiki](#):
>
> In fact, that theme has one, called [`foot-extra.html`](https://github.com/enten/hyde-y/blob/master/layouts/partials/foot-extra.html). Put your scripts in your own `foot-extra.html` , it should work out. 🙂

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