Skip to content

Customize the order of posts #26

Discussion options

You must be logged in to vote

Step 1: Add an "order" parameter to your post frontmatter

For each post, add an order parameter in the frontmatter section. Lower numbers will appear first.

---
layout: post
title: "First Post in Custom Order"
date: 2023-01-15
categories: ["jekyll"]
order: 1
---

Post content here...
---
layout: post
title: "Second Post in Custom Order"
date: 2023-02-20
categories: ["jekyll"]
order: 2
---

Post content here...

Step 2: Modify your blog layout to use the custom ordering

Edit your _layouts/blog.html file to sort posts by the order parameter:

<section class="articles">
  {% assign sorted_posts = site.posts | sort: 'order' %}
  {% for post in sorted_posts %}
  <article class="article">
    <h2 c…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@sharadcodes
Comment options

@sharadcodes
Comment options

Answer selected by Nitrohedge21
@Nitrohedge21
Comment options

@Nitrohedge21
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants