How do I go about setting up a carousel that showcases particular posts within a Jekyll website?

My goal is to set up a carousel that features specific posts, creating a visually appealing layout.

Since the jekyll theme I'm using comes equipped with Bootstrap 4, I decided to utilize a pre-existing carousel code from Bootstrap.

To achieve this, I contemplated adding a "slider" category in the front matter for marking posts to be displayed within the carousel. However, my limited expertise with liquid makes it challenging to pinpoint and display only those specific posts as a novice in Jekyll development.

I also attempted to use the Slider/Carousel plugin, which successfully showcased posts instead of placeholder images, but once again, I struggled to selectively choose individual posts for display.

Considering my beginner status, I believe utilizing the bootstrap slider would be more manageable to customize and feature certain posts within the carousel.

In summary, I aim to implement a carousel on Jekyll featuring distinct posts, yet my understanding of liquid falls short.

Below is the code snippet for the Bootstrap 4 slider without any liquid integration:

!--Carousel Wrapper-->
<div id="carousel-example-2" class="carousel slide carousel-fade" data-ride="carousel">
...
</div>
<!--/.Carousel Wrapper-->


Additionally, here's an attempt at customizing the carousel with Slider/Carousel: I included {% for post in site.posts %}, however, despite displaying all posts, the functionality doesn't align with my objective of selective post presentation.

{% assign letterstring = "a,b,c,d,e,f,g,h,i,j,k,l,m,n" %}
{% assign letters = letterstring | split: ',' %}

<div class="carousel__holder">
    <div class="carousel">
        {% for post in site.posts %}
            ... (remaining excerpt)
{% endfor %}
        <div class="carousel__track">
          <ul>
            {% for post in site.posts %}
    
            <li class="carousel__slide" style="background-image: url('{{ post.image }}');"><a href="{{ post.url }}">{{ post.title }}</a></li>
             
{% endfor %}
          </ul>
        </div>
        <div class="carousel__indicators">
            {% for post in site.posts %}
                ... (remaining excerpt)
{% endfor %}
        </div>
    </div>
</div>


Answer №1

I am not sure how to identify individual posts

Here is a code you can use to filter posts by a certain author:

{% assign sorted-posts = site.posts | where: "author","sharathdt" %}
{% for post in sorted-posts limit: 5 %}
  <li>{{post.title}}</li>
{% endfor %}

Source:

This method can be applied to any variable, such as filtering by is_featured: true.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Bootstrap scrollspy feature experiencing malfunction

I am encountering an issue with scrollspy on Bootstrap version 5.1. Despite following the examples in the documentation (links provided below), I am unable to make it work; there are no visible changes when scrolling. My goal is for the corresponding link ...

Arrange multiple elements in a column using the flexbox `justify-content` property

I have a div containing h1 and h2 tags. My objective is to center them both horizontally and vertically using flexbox. However, my current code aligns them diagonally like this: -------------- | | | h1h2 | | | --------- ...

Different "criteria" for CSS wildcard selectors using Selenium

There are several CSS webelements on my page with ids in the format: cell_[number]-button_[number] I am attempting to target ALL of these elements by using Selenium to locate all elements that begin with cell and include button: var elements = Util.driver ...

Scaled-down navigation when scrolling

Is there a way to make the navigation bar shrink when scrolling, similar to how it functions on this website? The transition on this site is so seamless. I'm guessing it's achieved with JQuery. ...

Animate sliding bar to move from the left using jQuery

I am currently experiencing an issue with a sliding animation on mouseover in the navigation. The animation works fine, but the problem arises when I hover over any menu item - the sliding bar starts from the very left instead of starting where the navigat ...

Excessive text in the input text area causing overflow

I am experiencing a minor issue with the primefaces inputTextArea. Whenever the text exceeds the assigned panel height, it overflows behind the next panel. Interestingly, clicking into the textarea resolves the problem temporarily, but on initial page view ...

loading dynamic content into an appended div in HTML using Angular

Here is the HTML code from my app.component.html file: <button mat-raised-button color="primary" mat-button class="nextButton" (click)="calculatePremium()"> Calculate </button> <div id="calcul ...

In HTML5, I am trying to figure out the best way to connect my webpage sections to the corresponding navigation links with the help of IDs (such as linking navhome to

I am in the process of redesigning a website to optimize it for mobile devices. Although I have completely restructured the site, I am encountering an issue where the main pages are not displaying properly. The header, navigation menu, sidebars, and a plac ...

Adjust the background color and transparency of a specific section using HTML

Is there a way to modify the background color or opacity of a specific area within an image? Take a look at my HTML, JavaScript, and CSS: function changeColor() { document.getElementById('testid').setAttribute("class", "style1"); } ...

An alternative solution for forms within forms

I'm in need of nested forms, but since they are not allowed in HTML, I've come up with a solution. I decided to have several submit buttons within one form. Now, my problem is figuring out how to determine which of the submit buttons is pressed ...

CSS Styles Not Sticking in Jquery

Hello everyone! I'm new here and I need some help. I want to change the background of a td element without losing the CSS styling that is currently applied to it. Right now, the background is repeating and tiling. Below is the script I am using: $ ...

The form within the while loop is only functioning with the initial result

Within a while loop, I have a form that is being processed with ajax. The issue is that it only works on the first form and not on the others. Can someone take a look? <?php while($a = $stmt->fetch()){ ?> <form method="post" action=""> ...

Swapping out background images for individual pages

How can I make sure that the background images stay fixed regardless of the amount of text on the page? I have two background images, one on the left and one on the right. The text article is overlaid on top of these images. However, each page has a differ ...

Adjusting the empty image source in Vue.js that was generated dynamically

Currently experimenting with Vue.js and integrating a 3rd party API. Successfully fetched the JSON data and displayed it on my html, but encountering issues with missing images. As some images are absent from the JSON file, I've saved them locally on ...

Issues with color scheme in Angular Material 18

While using (ng generate @angular/material:my--own-theme), I came across some code in own-theme.scss. Surprisingly, this code works for the palette included in Angular Material, but I prefer to use my own theme. Here's what was generated and what I di ...

What is the standard "placeholder" for a Select-box in Angular?

Currently in the process of developing a front-end web application with Angular 6, I have encountered a challenge. Specifically, I am working on creating a component that includes various select-boxes, resembling this setup: https://i.sstatic.net/6DmL9.pn ...

Set the minimum height of a section in jQuery to be equal to the height of

My goal is to dynamically set the minimum height of each section to match the height of the window. Here is my current implementation... HTML <section id="hero"> </section> <section id="services"> </section> <section id="wo ...

What causes certain images to have unspecified height and width measurements?

Currently, I am in the process of extracting image sizes from a website using a module called scraperjs. Most images have their height and width attributes defined, but some do not, resulting in the returned value being "undefined". How can I retrieve the ...

Adjusting the width of bars using JavaScript

Can anyone assist me with adjusting the width of bars in a horizontal bar graph based on percentage data? Check out my code on jsfiddle here Thank you in advance! var data = { "box1": { "bar1": "80%", "bar2": "60%", "bar3": ...

Displaying an array in HTML where one parameter serves as the key is a common task that

{ "Id": "12345", "length": [ { "review": { "1": { "request": [ { "days" ...