Featured Posts via Routes.yaml not working

Hi everyone!

Found multiple recs to just add:
order: featured desc, published_at desc
to the routes.yaml file so it reads

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

and reupload to get the featured posts in front. But I did this, several times, and it’s still descending order by date and the featured post is organized by date still. What am I doing wrong?

Thanks!

This notation /should/ give you all the featured posts first (newest first), THEN all the non-featured posts (newest first). Is that what you’re seeing? If that’s not what you wanted, can you explain what you’re trying to get?

To confirm, you’re uploading the routes.yaml from within the Ghost settings area (under labs), right?

oh… I bet this is a theme problem. What theme is this? Some themes don’t use routing for the homepage, but instead make a #get request that you’d need to edit in the theme files…

Got it. Yes, it’s just sorting descending order of posts, the featured post is in chronological order.
And yes, uploading under Labs. Tried it a few times, downloaded the Labs yaml file and it was the correctly edited one.

Using Casper - if something else, let me know. Much appreciated, Cathy!

Casper doesn’t do a get request on the index template, so that’s not it…

Can you try doing just order: featured desc ? Does that get the featured first?

And I assume you’ve got the correct spacing on that file? It should have two spaces before permalink, template, and order. Exactly two.

Ohh… hang on. [Routing always makes my head hurt.] You might want to try this as a route - see the example here:

Hm, tried the featured desc only and no change.
I just downloaded the file and added the order line, looks like just one space?
But added two spaces and reuploaded, with the featured line as this, but yeah, still no luck

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

Does it take a while for this to work? Like should I be waiting a few hours for it to update or something?

Nah, it should be instantaneous (unless you’ve got some fancy caching set up or something).

I’ll try to replicate -

.yaml files definitely need two spaces. I wonder if you’ve still got an error and you’re seeing the default behavior. Can you paste in your routes.yaml, using the </> button to make it as code, not the blockquote (") button?

Got it. See below!

routes:

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

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

1 Like