Broken Post URL for Featured Posts

I’m creating a custom featured posts block on the index.hbs, something like:

{{#get 'posts' filter='featured:true' limit='all' as |featured|}}
  {{#foreach featured}}
    <a href='{{ url }}''>{{ title }}</a>
  {{/foreach}}
{{/get}}

Then, to remove the duplicate featured posts from showing up in the current loop ({{#foreach posts}}), I’m using filter: featured:false within the collection.

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: featured:false

Featured posts are now excluded from the index loop, but the problem is that the URL for the custom featured posts block is broken with generated value. Something like this:

/p/d1c7c28a-9083-418d-953b-6d5d2baec30d/

I’m not sure if this is an issue or something related to what @Hannah said:

Propaply, the custom featured posts are excluded and no longer part of a collection because of the featured:false filter?

Any insights would be appreciated.

Ghost: 4.4.0

Collections change the URL of a post, if a post isn’t included in a collection then it has no URL which I think is what you are seeing.

It sounds like you may want to leave the default collection alone and use a channel for your homepage instead? https://ghost.org/docs/themes/routing/#channels

1 Like

Thanks, Kevin!

Yes, using a separate channel with a custom home.hbs is a good solution.

routes:
  /:
    template: home
    controller: channel
    filter: featured:false