Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-15T15:35:34.377Z
Answers.Text: Hi thanks for the help. Where would I add this?
Answers.UserDisplayName: user924248
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-15T15:57:57.373Z
Answers.Text: In your default module - https://nystudio107.com/blog/enhancing-a-craft-cms-3-website-with-a-custom-module
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-15T15:28:21.707Z
Answers.LastActivityDate: 2019-04-18T05:20:52.803Z
Answers.LastEditDate: 2019-04-18T05:20:52.803Z
Answers.UserDisplayName: Robin Schambach
Body: <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>
  
Tags: <templating><craft3>
Title: Extend templates from outside templates directory
ThreadText: # 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](https://docs.craftcms.com/v3/extend/template-roots.html) for this folder:
  
  ```php
  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  
  
  ---
  
  