Pagination on blog with only featured posts on front page

I have built a blog that shows only featured posts on the front page. The changes I made to index.hbs broke pagination, and I can not make it work again. Right now Esbens Hardenbergs blog shows the ten newest featured posts, and I’d like for Esbens Hardenbergs blog (Page 2) to show the next ten etc.

Right now /page/2/ gives a “[index.hbs] Cannot read property ‘hash’ of undefined” error 400.

I have some posts I’d like to reference later and have created an archive page for these un-featured posts.

Is there any way I can make pagination work with only my featured posts?

I have modified my index.hbs with code from this tutorial, in order to show only featured posts on the front page: How to Show Featured Posts on Homepage in Your Ghost Blog

Instead of changing the code of the index template, you can modify your routes.yaml file.
You can create a filter to assign only the featured posts to your home page.

Here’s the default route config:

You could modify it like this:

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: featured:true
1 Like

Thanks a lot, definitely a nicer way to go about this, I have changed my blog to do this instead. However, it does not solve my issue with pagination, as far as I can tell. When going to Esbens Hardenbergs blog (Page 2) I still get the error 400.

Did you revert the code changes?

Yeah I’m using the original index.hbs now, but still no dice.

Finally figured this out - was caused by a typo in my translation code. It is now working, thanks again for helping me out.

1 Like

I’m having a different and super weird issue now, though: The front page works as expected, but a lot of the time, I will get the preview-link for a post at the automated slug, and it will fail when clicking. This happens on a tag collection page, for example: /tag/bookmarks/

My current routes.yaml is:

routes:

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

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

And I’m on Ghost v. 4.48.9

I had a similar issue a while back with a 404 error. It just took a week or so for the changes I had made to propagate through the backend. It was odd and a little frustrating but it did go away after a while. Perhaps you are having the same issue? Let me know either way…

You have to make sure your posts belong to at least one collection.
Your main collection now doesn’t include non-featured posts.

See more details here:

and here:

thank you so much, I will have to try this. I ended up going with a very hacky solution and just displaying anything that is not featured, which is obviously not very flexible.

Thanks again, I kept digging and now it works. I tried to use the “fromPinboard” tag, but that never worked, however “frompinboard” seems to work just fine. It seems that the capital P somehow trips the system up.

Here is the routes.yaml that is working for me

routes:

collections:
  /bookmarks/:
    permalink: /tag/frompinboard/{slug}/
    template: bookmarks
    filter: tag:frompinboard
  /:
    permalink: /{slug}/
    template: index
    filter: featured:true

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