Creating Custom Collections with the _collections Directory in Jekyll

As you continue exploring Jekyll’s directory structure, you may find that posts and pages are not always enough to organize your content. Maybe you are building a portfolio, a documentation hub, or a recipe website. These content types do not fit neatly into the default _posts system. That is where collections come in. The _collections directory allows you to create custom content groups with their own structure, metadata, and templates. By using collections, you can turn your Jekyll site into a flexible content management system without sacrificing the simplicity of static sites.

Key Questions This Guide Will Answer

What are collections in Jekyll

Collections are groups of related content that behave like posts but are not stored in the _posts folder. They give you flexibility to define your own content type. For example, you can have a _recipes folder to manage cooking recipes or a _projects folder for portfolio items. Each item inside the collection can have front matter just like posts, and you can loop through them using Liquid.

How do you enable a collection in _config.yml

To use collections, you must define them inside _config.yml. For example:

collections:
  recipes:
    output: true
  projects:
    output: true

This tells Jekyll to look for _recipes and _projects directories and generate pages for them. The output: true setting means each item will get its own page in the final site. If you set it to false, the collection data will still be available but no standalone pages will be generated.

How do you create and organize collection files

Once defined, you create a folder such as _recipes in your project root. Inside, each file represents an item in the collection:

_recipes/
  pasta.md
  salad.md

Each file should have front matter:

---
title: "Fresh Garden Salad"
ingredients:
  - lettuce
  - tomato
  - cucumber
---
A simple salad recipe full of fresh vegetables.

Collections are not restricted to Markdown; you can use HTML or other file types as needed.

How do you access collection data in templates

Accessing collections in templates is straightforward. For example, to loop through a recipes collection:

{% raw %}{% for recipe in site.recipes %}
  <h2>{{ recipe.title }}</h2>
  <p>{{ recipe.content | markdownify }}</p>
{% endfor %}{% endraw %}

This allows you to display all recipes on a single page or create category-based listings. You can also use collection metadata, such as ingredients, to generate filters or structured layouts.

What are practical use cases for collections

Collections open the door to a wide range of use cases beyond blogging:

  • Portfolios – Showcase projects with details, images, and links.
  • Recipes – Organize cooking instructions in a structured format.
  • Case studies – Document success stories or customer projects.
  • Documentation – Break down sections of a manual into reusable chunks.
  • Events – List conferences, meetups, or workshops with dates and details.

In short, if your content does not fit neatly into posts or pages, collections are the solution.

How should you name and structure collections

Here are some tips for effective collection management:

  • Use clear, plural names like recipes, projects, or events.
  • Keep related files together in their respective folders.
  • Store images or assets in a separate assets folder, not inside the collection.
  • Define useful metadata in front matter, such as categories, dates, or tags.

This structure ensures your site stays organized as it grows.

What common issues should you avoid

Beginners sometimes encounter problems with collections:

  • Forgetting to enable the collection in _config.yml, causing files not to load.
  • Using incorrect folder names (collections must start with an underscore).
  • Expecting collection files to behave exactly like posts (collections have no default date handling unless added manually).
  • Placing collection folders inside other directories instead of the project root.

Fortunately, these mistakes are easy to fix once you understand the rules.

What comes after mastering collections

After learning collections, you can combine them with the _data folder to build advanced features. For example, you might use a data file to store author bios and reference them in your case study collection. You can also create custom layouts for each collection type to give them a unique look. Finally, consider adding pagination or search functionality to make navigating large collections easier.

Final Thoughts

The _collections directory is one of Jekyll’s most powerful tools for building custom websites. Whether you are running a portfolio, recipe site, or technical documentation, collections allow you to go beyond simple blogs and organize your content the way you need. Once you master collections, your GitHub Pages site becomes much more than a static blog—it becomes a structured, professional, and scalable content platform.

What Should You Do Next

Create your first collection today. Add a folder like _projects, define it in _config.yml, and add a few Markdown files with metadata. Then loop through them in a layout and see how flexible collections can be. Once you feel comfortable, experiment with combining collections, data files, and includes to create highly modular Jekyll sites that are easy to maintain and expand.