How to loop over any collection type in Jekyll


Here’s how to put a single image into a post, using a Bootstrap 4 card. This shows how to mingle Markdown with HTML, too.

Jekyll, a static site generator.
{ % for collection in site.collections % }
                       
 { % assign name = collection.label % }
 <section>
   <h1>{ { name } }</h1>
 </section>

{ % endfor % }
  
  <section>
    <h1>blogposts</h1>   
  </section>

  
  <section>
    <h1>money_savings</h1>   
  </section>

  
  <section>
    <h1>portfolio</h1>   
  </section>

  
  <section>
    <h1>posts</h1>   
  </section>

  
  <section>
    <h1>product_reviews</h1>   
  </section>

  
  <section>
    <h1>projects</h1>   
  </section>

  
  <section>
    <h1>travel</h1>   
  </section>

  
  <section>
    <h1>travel_africa</h1>   
  </section>

  
  <section>
    <h1>travel_europe</h1>   
  </section>

  
  <section>
    <h1>travel_guides</h1>   
  </section>

  
  <section>
    <h1>tutorials</h1>   
  </section>
Posted on 10 Mar 2018 by Joel Murphy. Last updated: October 15, 2019.


Share your thoughts on: 'How to loop over any collection type in Jekyll':

πŸ‘€ Looking for more content?

There's plenty more content to explore: