# Referencing a template in a directory in routes.yaml

**URL:** <https://forum.ghost.org/t/referencing-a-template-in-a-directory-in-routes-yaml/6447>\
**Category:** Routing\
**Created:** [March 25, 2019, 9:12pm UTC](https://forum.ghost.org/t/referencing-a-template-in-a-directory-in-routes-yaml/6447 "2019-03-25T21:12:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmckulka](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cmckulka/32/2965_2.png) [@cmckulka](https://forum.ghost.org/u/cmckulka)\
**Post date:** [March 25, 2019, 9:12pm UTC](https://forum.ghost.org/t/referencing-a-template-in-a-directory-in-routes-yaml/6447/1 "2019-03-25T21:12:42Z")

</div>

I am doing some proof of concept work with Ghost and so far am very impressed.

I have successfully created a custom template, added it to routes.yaml and included it in my nav. All easy stuff.

I was hoping to put my custom, one off templates in a sub directory to keep them all together and separate from the default theme templates.

For example I wanted to play the custom templates at `content/themes/casper/custom_templates/` vs. just in `content/themes/casper/`. Unfortunately I get an error when I load the URL (route) that references that that template.

Here’s the routes section from my routes.yaml:

```auto
routes:
  /custom/: custom
  /custom2/: custom_templates/custom

```

Going to /custom/ works. Going to /custom2/ produces a 500 error with the following text:

```auto
ENOENT: no such file or directory, open '/Users/Chris/code/blog_scratch/ghost/local/content/themes/casper/custom_templates/default.hbs'

```

Do the templates have to be in the “root” of the theme?

Thanks,  
Chris

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [March 26, 2019, 11:16am UTC](https://forum.ghost.org/t/referencing-a-template-in-a-directory-in-routes-yaml/6447/2 "2019-03-26T11:16:38Z")

</div>

@cmckulka it sounds like you may have `{{!< default}}` in your nested template which is telling the renderer to use a `default.hbs` template in the current directory as the layout.

If you do have that in there could you try changing that to `{{!< ../default}}`?

---

<div class="post-metadata">

**Author:** ![cmckulka](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cmckulka/32/2965_2.png) [@cmckulka](https://forum.ghost.org/u/cmckulka)\
**Post date:** [March 26, 2019, 3:28pm UTC](https://forum.ghost.org/t/referencing-a-template-in-a-directory-in-routes-yaml/6447/3 "2019-03-26T15:28:17Z")

</div>

🤦‍♂️

Yes, that was exactly it. 😳 Seems entirely obvious now!

Thanks much for the quick response!

Chris

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/b/ba9ce5100b8bb264586f4f572545596b2ce3f081.png) [@system](https://forum.ghost.org/u/system)\
**Post date:** [April 9, 2019, 3:41pm UTC](https://forum.ghost.org/t/referencing-a-template-in-a-directory-in-routes-yaml/6447/4 "2019-04-09T15:41:35Z")

</div>

Closed on April 9, 2019, 3:41pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
