# Featured post or popular post

**URL:** <https://talk.jekyllrb.com/t/featured-post-or-popular-post/5157>\
**Category:** Help\
**Created:** [October 28, 2020, 2:30am UTC](https://talk.jekyllrb.com/t/featured-post-or-popular-post/5157 "2020-10-28T02:30:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahdim8m](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@mahdim8m](https://talk.jekyllrb.com/u/mahdim8m)\
**Post date:** [October 28, 2020, 2:30am UTC](https://talk.jekyllrb.com/t/featured-post-or-popular-post/5157/1 "2020-10-28T02:30:24Z")

</div>

How to add the category of featured post or popular post?

---

<div class="post-metadata">

**Author:** ![BillRaymond](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/billraymond/32/5963_2.png) [@BillRaymond](https://talk.jekyllrb.com/u/BillRaymond)\
**Post date:** [October 29, 2020, 9:27pm UTC](https://talk.jekyllrb.com/t/featured-post-or-popular-post/5157/2 "2020-10-29T21:27:50Z")

</div>

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:  
https://www.youtube.com/embed/6oKO-7gsM4s?feature=oembed&wmode=opaque&list=PLWzwUIYZpnJuT0sH4BN56P5oWTdHJiTNq&start=8

Or, reference my two posts with included video links here on Jekyll Talk:

> [@Learn how to add featured images to your posts](https://talk.jekyllrb.com/t/learn-how-to-add-featured-images-to-your-posts/4852):
>
> As I started building my blog, I realized it would be really nice to have a featured image that appears above my blog post. The image gets a reader’s attention and sets the tone for the content they will read. In this 2-part video series, I show you how to do that using the standard minima site Jekyll ships with. You can take these ideas and concepts and add them to your site. I am an occasional developer, so if you have any insights on how to improve, please feel free to offer your constructiv…

> [@Learn how to add featured images to your posts](https://talk.jekyllrb.com/t/learn-how-to-add-featured-images-to-your-posts/4852):
>
> As I started building my blog, I realized it would be really nice to have a featured image that appears above my blog post. The image gets a reader’s attention and sets the tone for the content they will read. In this 2-part video series, I show you how to do that using the standard minima site Jekyll ships with. You can take these ideas and concepts and add them to your site. I am an occasional developer, so if you have any insights on how to improve, please feel free to offer your constructiv…

Here’s the GitHub repo:

> **[GitHub - BillRaymond/jekyll-featured-images: Sample Jekyll site that shows...](https://github.com/BillRaymond/jekyll-featured-images)**
>
> Sample Jekyll site that shows how to implement featured images on posts and post feeds. - BillRaymond/jekyll-featured-images

And here is an example of what the code looks like:

> **[Blog](https://billraymond.github.io/jekyll-featured-images/feed/blog)**
>
> This website was designed to help you learn how to add featured images to posts and post rolls. To watch video training and learn more, view the readme file on my GitHub repo.
