<p>You need to define and register your <a href="https://docs.craftcms.com/v3/extend/template-roots.html" rel="nofollow noreferrer">template roots</a> for this folder:</p>

<pre class="lang-php prettyprint-override"><code>Event::on(
    View::class,
    View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS,
    function(RegisterTemplateRootsEvent $e) {{
        $e-&gt;roots['my-fancy-prefix'] = 'someDir';
    }
);
</code></pre>

CC BY-SA 4.0
2019-04-15T15:35:34.377Z
Hi thanks for the help. Where would I add this?
user924248
CC BY-SA 4.0
2019-04-15T15:57:57.373Z
In your default module - https://nystudio107.com/blog/enhancing-a-craft-cms-3-website-with-a-custom-module
Robin Schambach
CC BY-SA 4.0
2019-04-15T15:28:21.707Z
2019-04-18T05:20:52.803Z
2019-04-18T05:20:52.803Z
Robin Schambach
<p>I have a setup where I'm using a component library that I have as an npm package. To use these components I need to extend templates that live outside of the /templates directory. So I need to achieve something like:</p>

<p><code>{% extends "../../../../node_modules/design-system/page-templates/_template.njk" %}</code></p>

<p>I will be extended from within a template that is located from within the /templates directory but allows for extends from outside of it.</p>

<p>Any help would be great.</p>

<templating><craft3>
Extend templates from outside templates directory
# Extend templates from outside templates directory

(Asked by: username_0 on 2019-04-15)

I have a setup where I'm using a component library that I have as an npm package. To use these components I need to extend templates that live outside of the /templates directory. So I need to achieve something like:

`{% extends "../../../../node_modules/design-system/page-templates/_template.njk" %}`

I will be extended from within a template that is located from within the /templates directory but allows for extends from outside of it.

Any help would be great.

**Tags:** templating, craft3

---

## 1 answers

### Answer by username_1 on 2019-04-15. Score: 1

You need to define and register your template roots for this folder:
Event::on(
    View::class,
    View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS,
    function(RegisterTemplateRootsEvent $e) {{
        $e->roots['my-fancy-prefix'] = 'someDir';
    }
);

> **Comments:**
> **username_0**: Hi thanks for the help. Where would I add this?  
> **username_1**: In your default module - https://nystudio107.com/blog/enhancing-a-craft-cms-3-website-with-a-custom-module  

---

