Pages retrievable as posts

When writing Ghost themes, it would be really useful if you could retrieve pages along with posts using the {{#get}} command. Because pages also have tags, it would be valuable to have them as a retrievable item in the tag page, for instance if you could write {{#foreach post+page}} or similar so it would list them all. It would just make things more flexible for websites which are a little more than just blogs.

You can actually already do that, though it looks like the docs don’t specify this -

{{#get "pages"}}
  {{#foreach pages}}
    {{!-- do something! --}}
  {{/foreach}}
{{/get}}

Example content of pages object:

[ { id: '5d0ae1b3e93ae30345018c75',
    uuid: '71665235-1c8d-427a-8b74-4eace570e01d',
    title: 'Test page',
    slug: 'test-page',
    html: '<p>Testing</p>',
    comment_id: '5d0ae1b3e93ae30345018c75',
    feature_image: null,
    featured: false,
    page: true,
    meta_title: null,
    meta_description: null,
    created_at: '2019-06-19T20:30:27.000-05:00',
    updated_at: '2019-06-19T20:30:44.000-05:00',
    published_at: '2019-06-19T20:30:33.000-05:00',
    custom_excerpt: null,
    codeinjection_head: null,
    codeinjection_foot: null,
    og_image: null,
    og_title: null,
    og_description: null,
    twitter_image: null,
    twitter_title: null,
    twitter_description: null,
    custom_template: null,
    canonical_url: null,
    primary_author: null,
    primary_tag: null,
    url: 'http://ghost.dev:2368/test-page/',
    excerpt: 'Testing' } ]

Yes I’ve found that, thank you for your reply! What I’m asking if there was a way to retrieve both Posts and Pages as one object. I’d also like them to be available without using the {{#get}} handlebars function in tag pages. What do you think?

1 Like

I don’t think this is possible because Posts and Pages are considered two separate resources, irrespective of how they’re stored. Also, pages are more intended to be static content, so it seems really hacky to try to mix the response of posts and pages.

I don’t think there’s a super easy way to do this. There are two methods to pull data in - dynamic routing and the get helper. Dynamic Routing would only be useful if you were trying to inject data to a specific route

I agree with @willston - it would be very handy to be able to retrieve everything that has a particular tag, irrespective of whether it’s a post or page.

These are so similar in every other respect, I’m surprised it’s not possible.