Understanding Jekyll Collections: When Posts Aren't Enough
If you’ve been using Jekyll for a while, you’ve probably run into this problem: not everything fits neatly into the chronological blog post model.
That’s where Jekyll collections come in - and honestly, they’re a game-changer once you understand how to use them properly.
What Are Jekyll Posts?
Posts are Jekyll’s original content type, designed for chronological content like blog entries.
Characteristics of Posts
- Date-based: Filenames must include dates (
YYYY-MM-DD-title.md
) - Chronological ordering: Automatically sorted by date
- Built-in pagination: Easy to paginate through posts
- RSS feeds: Automatically included in site feeds
- Categories and tags: Built-in taxonomy support
Example Post Structure
---
layout: post
title: "My Blog Post"
date: 2025-07-20
categories: [blogging, jekyll]
tags: [tutorial, web-development]
---
What Are Jekyll Collections?
Collections are groups of related documents that don’t need to follow chronological order.
Characteristics of Collections
- Flexible naming: No date requirements in filenames
- Custom organization: Organize by topic, not time
- Custom metadata: Define your own front matter fields
- Flexible URLs: Control permalink structure
- Queryable: Easy to filter and sort programmatically
Example Collection Structure
---
layout: post
title: "API Documentation"
category: "technical"
difficulty: "advanced"
version: "2.1"
last_updated: 2025-07-20
---
When to Use Each
Use Posts For:
- Blog entries - Personal thoughts, announcements, news
- Time-sensitive content - Updates, releases, events
- Chronological narratives - Project progress, learning journeys
- Regular publishing - Weekly updates, monthly reviews
Use Collections For:
- Documentation - API docs, user guides, tutorials
- Portfolio items - Projects, case studies, work samples
- Reference material - Recipes, tools, resources
- Structured content - Team members, products, services
Setting Up Collections
1. Configure in _config.yml
collections:
tutorials:
output: true
permalink: /tutorials/:name/
projects:
output: true
permalink: /work/:name/
2. Create Collection Directories
_tutorials/
getting-started.md
advanced-techniques.md
_projects/
project-alpha.md
project-beta.md
3. Set Default Layouts
defaults:
- scope:
path: "_tutorials"
type: "tutorials"
values:
layout: "tutorial"
category: "learning"
Practical Examples
Blog Post Example
---
layout: post
title: "Why I Switched to Jekyll"
date: 2025-07-20
categories: [blogging, tools]
tags: [jekyll, static-sites, productivity]
---
Last month, I decided to migrate my blog from WordPress to Jekyll...
Collection Item Example
---
layout: project
title: "E-commerce Platform"
technology: ["React", "Node.js", "MongoDB"]
status: "completed"
client: "TechCorp"
duration: "6 months"
featured: true
---
This project involved building a scalable e-commerce platform...
Advanced Techniques
Querying Collections
Cross-referencing Content
<!-- In a blog post, reference related how-tos -->
Custom Sorting
Best Practices
Content Organization
- Use descriptive filenames:
advanced-git-workflows.md
nottutorial1.md
- Consistent front matter: Define standard fields for each collection
- Logical grouping: Group related content in the same collection
Performance Considerations
- Limit collection size: Large collections can slow build times
- Use pagination: For collections with many items
- Optimize images: Compress images in collection items
SEO Optimization
- Unique titles: Each item should have a distinct title
- Meta descriptions: Use excerpts or custom descriptions
- Structured data: Add schema markup for better search visibility
Conclusion
Choose posts for time-based content and collections for everything else. This approach gives you the flexibility to organize content logically while maintaining Jekyll’s simplicity and power.
The key is understanding your content’s nature and choosing the right tool for the job. Most sites benefit from using both: posts for regular updates and collections for structured, reference material.