Hi, I’m running the latest 2.x release, and trying to figure out the dynamic routing feature.
Basically, I want a ‘page’ with slug ‘home’ to appear as the homepage on root (/), and blog posts under /blog/, but for the homepage only a blank template renders (although a page with slug ‘home’ exists), and the blog renders without a header.
Here’s the routes.yaml:
routes:
/:
data: page.home
template: index
collections:
/blog/:
permalink: /blog/{slug}/
template: tag
taxonomies:
tag: /blog/topic/{slug}/
author: /blog/author/{slug}/
@vicnick I think the problem is your use of index as your homepage template.
routes:
/:
data: page.home
template: index
Will render the index.hbs template but only make {{page}} available which is unlikely to work because index.hbs typically expects {{posts}}.
What you could try instead is specifying your page.hbs template to be used:
routes:
/:
data: page.home
template: page
Or alternatively, you could create a completely custom home page (bear in mind you’ll still only have access to {{page}} in the template due to the way the data: attribute works):
Setting the template to page didn’t work either. It renders the page with a header and footer but no page content in between, although a page with slug home exists with content (otherwise accessible as /home just fine).
Has anyone tried something like this before, to basically have a static homepage?!
I think the problem is that the data: page.home attribute makes the resource available as {{page}} and not as {{post}} and that’s why you are seeing a blank page. This is the default behaviour - Ghost uses the resource type (in this case “page”) as name for the theme object.