Creating a Related Pages panel item for a 'Read Next' section after blog post detail page

Hi there, I’m following the related articles post in the cookbook trying to create a page picker panel in the sidebar when editing a blog post, that lets me choose other published blog posts (articles) on my site.

I’ve added:

related:
    type: pages
    query: page.siblings(false)
    empty: "No read next pages selected"

to the foot of my article.yml (which I use for blog posts)

However it only ever shows an add button which prompt me to add a page, not select a sibling blog post.

How can I change this to allow me to select other posts within the same parent folder? or even any page on the side - I don’t mind).

adding the following manually to a specific blog post interestingly doesn’t make anything show in the admin

Coverimage:

- bear-notes-post.png

---

Related:

- journal/making-remote-work-work
- journal/eliminating-distractions-as-a-generalist

or in my frontend template using the following in the template

$related = $page->related()->toPages();

…which makes me think my query is wrong.

Any suggestions as to where I’m going wrong? Articles live in a journal folder e.g. https://www.alpower.com/journal and there’s nothing else called related inside my article.yml file.

Thanks!! Al

Looks like you created a pages section rather than a pages field. If you can’t figure it out yourself, please post your blueprint.

1 Like

Thanks @pixelijn - that put me on the right track. My confusion was I’d put it under the gallery entry, instead of under fields, and shifting it up so it was in the fields list and indenting in a few levels did the trick.

Posting what worked below in-case it helps someone else. Thanks again. :heart:

sidebar:
width: 1/3
sections:
  meta:
    type: fields
    fields:
      coverimage:
        label: Cover Image
        type: files
        headline: Cover
        layout: cards
        info: "{{ file.dimensions }}"
        template: cover
        min: 0
        max: 1

      related:
        label: Related Pages
        type: pages
        query: page.siblings(false)
        empty: "No read next pages selected"

  gallery:
    type: files
    layout: cards