Pinning a featured post to top of home page, on Ghost Pro, using Lyra

I changed my pinned.hbs to limit=“2”, checked “Feature this post” on two non-consecutive posts, and both posts appeared in the first two positions of the index page. Your index.hbs must have the {{> “pinned”}} line above the {{#foreach posts}} line. If you use filter=“featured:true” in pinned.hbs then you should not have the {{#unless featured}} block there. I am using a modified Casper theme, so maybe your theme is causing the problem.

Thanks for the information sharing

Hi @Sage,
If you need any help, please PM me. I am available to help you directly.

Thanks

You can change the routes.yaml file to make the featured posts come first. Download it in labs .

If you add the line: order: featured desc, published_at desc

So it will be this:

routes:

collections:
  /:
permalink: /{slug}/
template: index
order: featured desc, published_at desc

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

Oh that’s brilliant. Thank you @psychokillerblog, I would never have noticed this feature, it works a treat and is a piece of cake. Once again I narrowly performing surgery on the Theme, despite making lots of varied changes to the site! This is a documented, but hard to find, feature.

Just one tip for others: YAML relies on indentation using spaces, and order needs to appear under the root collection. So it should be:

routes:

collections:
  /:
    permalink: /{slug}/
    template: index
    order: featured desc, published_at desc

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

And then restart Ghost with ghost restart.