How to add the category of featured post or popular post?
Your Jekyll site is static, so calculating what post is popular using visitor data will probably be more trouble than it is worth. I am sure there are articles on how to do that, but I doubt it is easy
Here are some options you can try out, including some videos I created on the topic:
Option #1: Display the latest post
{%- for post in site.posts limit: 1 -%}
{{- post.title -}}
{%- endfor -%}
Option #2: Display what you have decided is a featured or popular post
In the front matter of the post, create a custom variable called featuredPost
(you decide on the name) and then write code that looks like this:
---
layout: post
date: 2020-08-10 12:30:00 -0700
title: This is a great featured post
featuredPost: true
---
Welcome to this great post!
In the page that displays the post(s), use the custom variable:
{%- assign fp = site.posts | where: 'featuredPost', true -%}
{%- for fp in site.posts -%}
{{- post.title -}}
{%- endfor -%}
I created a 2-part video series on how to add a featured image to your site. There is also a 3-part series on creating reusable code to display a unique featured post, which is what you are after.
Start with this video and then keep going through the playlist:
Or, reference my two posts with included video links here on Jekyll Talk:
Here’s the GitHub repo:
And here is an example of what the code looks like: