# Dynamic route triggering custom template on pagination

**URL:** <https://forum.ghost.org/t/dynamic-route-triggering-custom-template-on-pagination/51671>\
**Category:** Routing\
**Created:** [October 15, 2024, 2:10am UTC](https://forum.ghost.org/t/dynamic-route-triggering-custom-template-on-pagination/51671 "2024-10-15T02:10:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jennifilm](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/jennifilm/32/27591_2.png) [@jennifilm](https://forum.ghost.org/u/jennifilm)\
**Post date:** [October 15, 2024, 2:10am UTC](https://forum.ghost.org/t/dynamic-route-triggering-custom-template-on-pagination/51671/1 "2024-10-15T02:10:52Z")

</div>

Kia ora!

I’ve just been working on setting up dynamic routing so I can combine my Ghost site with my portfolio site without clogging up my newsletter. I’m pretty much all set except for an odd pagination issue!

I’m self hosting, running 5.94.0 and using a modified version of Source 1.3.2.

The issue I have is that pagination on my home (`/`) page triggers the same `home` template on `/page/2`, showing the exact same content, rather than the `index` template that often triggers with other Source installs.

Here’s my routes.yaml - I’m wondering if there’s something missing to get pagination working correctly?

```auto
routes:

collections:
  /:
    template: home
    permalink: /newsletter/{slug}/
    filter: primary_tag:newsletter
  /art/:
    permalink: /art/{slug}/
    template: collection
    filter: primary_tag:art
    data: tag.art
  /speaking/:
    permalink: /speaking/{slug}/
    template: collection
    filter: primary_tag:speaking
    data: tag.speaking
  /essays/:
    permalink: /essays/{slug}/
    template: collection
    filter: primary_tag:essay
    data: tag.essay

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

```

`home.hbs` is largely unmodified from Source:

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

{{> "components/header" headerStyle=@custom.header_style}}

{{#match @custom.header_style "!=" "Highlight"}}
    {{> "components/featured" showFeatured=@custom.show_featured_posts limit=4}}
{{/match}}

{{> "components/cta"}}

{{> "components/post-list" feed="home" postFeedStyle=@custom.post_feed_style showTitle=true showSidebar=@custom.show_publication_info_sidebar}}

```

and the only modification I’ve made otherwise is inserting a custom `about-card` into `header-content`.

Is there a way to force `/page/2` to load `index` rather than `home`? Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [October 15, 2024, 4:08am UTC](https://forum.ghost.org/t/dynamic-route-triggering-custom-template-on-pagination/51671/2 "2024-10-15T04:08:12Z")

</div>

Which header style setting are you using?

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [October 15, 2024, 4:09am UTC](https://forum.ghost.org/t/dynamic-route-triggering-custom-template-on-pagination/51671/3 "2024-10-15T04:09:20Z")

</div>

Actually, humor me a second - can you remove the template setting from the / collection? I’m thinking that’ll default you over to index, but then the / route will load home… I’m hoping!

---

<div class="post-metadata">

**Author:** ![jennifilm](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/jennifilm/32/27591_2.png) [@jennifilm](https://forum.ghost.org/u/jennifilm)\
**Post date:** [October 15, 2024, 4:20am UTC](https://forum.ghost.org/t/dynamic-route-triggering-custom-template-on-pagination/51671/4 "2024-10-15T04:20:13Z")

</div>

Thanks for your help! That’s done something odd - it fixes the pagination, but breaks the filtering, so now `/` includes all posts, not just the ones with the primary tag `newsletter`. I’m using the magazine header.

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [October 15, 2024, 4:27am UTC](https://forum.ghost.org/t/dynamic-route-triggering-custom-template-on-pagination/51671/5 "2024-10-15T04:27:24Z")

</div>

From memory, Source doesn’t respect routing. You’d need to edit the get requests to include your filter.

---

<div class="post-metadata">

**Author:** ![jennifilm](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/jennifilm/32/27591_2.png) [@jennifilm](https://forum.ghost.org/u/jennifilm)\
**Post date:** [October 15, 2024, 4:28am UTC](https://forum.ghost.org/t/dynamic-route-triggering-custom-template-on-pagination/51671/6 "2024-10-15T04:28:08Z")

</div>

Oh hold up - the filtering doesn’t work regardless of whether the template setting is there, so that’s a separate error I haven’t quite figured out (but would still LOVE help with).

Interestingly, with the template setting removed, the home page appears as expected (using `home`) but with posts **not** tagged `newsletter`, while page/2 lists only `newsletter` posts, but lists all of them.

---

<div class="post-metadata">

**Author:** ![jennifilm](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/jennifilm/32/27591_2.png) [@jennifilm](https://forum.ghost.org/u/jennifilm)\
**Post date:** [October 15, 2024, 4:28am UTC](https://forum.ghost.org/t/dynamic-route-triggering-custom-template-on-pagination/51671/7 "2024-10-15T04:28:20Z")

</div>

Oh true! Okay that’s simple enough - thank you!
