Dynamic Routing - Create new index page and access all Posts

If you’re looking for some help, it’s important to provide as much context as possible so that people are able to assist you. Try to always mention:

  • What’s your URL? This is the easiest way for others to debug your issue

  • What version of Ghost are you using?

  • What configuration?

The default configuration

  • What browser?
  • What errors or information do you see in the console?
  • What steps could someone else take to reproduce the issue you’re having?

I have this website https://vfpoetry.com/ and I would like to create an index page on the
https://vfpoetry.com/my-poems/ path and I would like to access the whole list of posts.

What I have done is used the following dynamic routing


    permalink: '{globals.permalinks}' # special 1.0 compatibility setting. See the docs for details.
      - index
    permalink: /my-poems/
      - index

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

and I’ve created a template named my-poems.hbs with the following html

{{!< default}}
{{! The tag above means - insert everything in this file into the {body} of the default.hbs template }}

{{! The main content area on the homepage }}
<main id="content" class="content mxn2 js-grid">

    {{#foreach posts}}
        <article class="{{post_class}} px2 border-box post--grid {{#if featured}}post--featured{{/if}}">
            <div class="p3 bg-white box-shadow">
                {{#if feature_image}}
                    <div class="post-image mxn3 mb3">
                        <a href="{{url}}"><img src="{{img_url feature_image}}" alt=""></a>
                <header class="post-header">
                    <h2 class="post-title mt0 break-word"><a class="black" href="{{url}}">{{{title}}}</a></h2>
                <div class="post-excerpt h5 light">
                    <p class="mb0">{{excerpt}} <a class="read-more" href="{{url}}">&raquo;</a></p>


{{! Previous/next page links - displayed on every page }}

Now When I visit the page I cannot see the posts data, its empty.

How can I access the posts from that page? I just need the whole post list and not a filtered one.

Have you read https://docs.ghost.org/docs/dynamic-routing already?

Yes and apparently I should have access to the #posts context but in reality its not. How can I debug this?

You have to use a filter, otherwise the first collection will own every post.

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