Dynamic routes gives correct content, but uses wrong template

(I am using Ghost 2.1.1, Firefox on Ubuntu, Ubuntu server.) I am using dynamic routes to have a static home page and to have the url /research/ for /tag/research/. Here is my routes.yaml:

routes:
/:
data:
post: page.about-me
template: page

/research/:
controller: channel
filter: tag:[research]
template: tag

collections:

taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/

I want the homepage to look like this, yet it looks like that. As the HTML shows, the template used on the former is the correct page-template, while it is the home-template (according to the css classes). Similarly, I want the research pages to look like this, yet they look like that. Again, the content is correct, but the template isn’t.

So which part of passing templates do I not understand correctly? (I did read the whole dynamic routes page, but may have misunderstood bits and bops.) I also tried the /research/ part without the template: tag part, which was different, but also not what I wanted. It had the home-page title, rather than the “Research” title.

Thanks

OK, some update, as I clearly don’t understand dynamic routes. I use once the template page, and once home – which is an identical copy of page.hbs – yet the route with template home gives an error 500 with “Cannot read property ‘match’ of undefined” while the one with page does not. Here is part of the routes.yaml:

routes:
/:
data:
post: page.test
template:
- page

/test/:
data:
post: page.test
template:
- page

/test1/:
data:
post: page.test
template:
- page

/test2/:
data:
post: page.test
template:
- home

/test3/:
data:
post: page.test2
template:
- home

/test4/:
data:
post: page.test3
template:
- page

And here are the links to /, /test/, /test2/, /test3/, and /test4/.

Should I alter something when copying a template? Even if, I still would have thought that routes uses the same template no matter what, so why do I get different behavior? And how can I measure this or start debugging it?

Thanks for any hints on debugging - I am having a hard time setting a static home page somehow…

Cannot read property ‘match’ of undefined

This is usually caused by an error in the target template.
Which theme are you using?

OK, classic rookie mistake. I forgot to run:

ghost restart

after copying the new home.hbs template. So now all the pages look the same and none throw an error 500.

I now changed my routes.yaml so that it does not remap /test3/ or /test4/ anymore. So now I am back to my previous problem where /test3/ has different styling than / even though I would have thought that the routes.yaml causes the page to load with the page.hbs template.

How can I find out which template gets loaded - either on the client or server-side? I can tell that the is different on those pages, but I don’t know why.

Thanks,
Marc

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