Referencing a template in a directory in routes.yaml


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:

  /custom/: custom
  /custom2/: custom_templates/custom

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

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?



@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}}?



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

Thanks much for the quick response!


closed #4

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