Previous/next post buttons in Elements CMS

Can anyone tell me if it is possible to create previous and next post buttons for Elements CMS? There doesn’t seem to be a component making that possible for simple minds like my own.

Hi @PouwelW

we don’t currently have a component that does this, but it’s something we’d love to add :slightly_smiling_face:

Hi Ben,

I hope you will find time in the near future to realize such a component. It would bring blogging in Elements to a higher level.

But you don’t necessarily have to wait for Ben either.

You can create your own NEXT/PREV navigation using the frontmatter.

It might take one or two extra lines, but it works absolutely perfectly for me.

Thanks Pegasus. But I’m not a developer, just someone who publishes blog posts on his own, personal site. I do prefer a dedicated component for this. Or, if that’s possible, copying some CSS-code in the Advanced section of a regular button.

You don’t need to know how to code for this.

I would keep it simple.

You can just add something like this to the frontmatter of your Markdown files:

prevPost:
  name: "This is the Prev Post"
  path: "here-the-slug-of-your-prev-post"

nextPost:
  name: "This is the Next Post"
  path: "here-the-slug-of-your-next-post"

Then you can output these values using Twig, just like you’re probably already doing with other data in your blog.

For example, inside your buttons:

{{ item.prevPost.name }}

{{ item.nextPost.name }}

Then simply link the two buttons using:

{{ item.prevPost.path }}

{{ item.nextPost.path }}

And that’s it — you have your own custom NEXT/PREV buttons.

If you’ve already set up your blog, assigned a title, and linked your blog posts, this should be pretty straightforward to implement.

If you run into any problems, just let me know and I’ll be happy to help.

Thanks for your suggestion and for your offer to help. But I prefer the DevPack that @MichaelDroste so kindly developed when he read my post. That works fine for me and doesn’t require changing the FrontMatter of my md-files. It’s great to notice how helpful people are on this forum.