Collections are the data that blocks display. While blocks define page layouts and sections, collections define the actual entities: Industry, Client, Product, Team Member. A single collection can be used across multiple blocks and pages.
This guide walks through creating a collection from scratch.
Collections vs Blocks: Understanding the Relationship
Think of it this way:
Collections = Data (the "what")
Industry (Retail, Healthcare, Hospitality)
Client (Company A, Company B)
Team Member (John, Sarah, etc.)
Blocks = Display (the "how")
FeaturedIndustries block displays industries
ClientGrid block displays clients
TeamCarousel block displays team members
One collection (Industry) can be displayed by multiple blocks (FeaturedIndustries, IndustryDetail page, FilterBar). Collections are reusable; blocks are layout-specific.
When to Create a Collection
Create a collection when:
You have multiple instances of the same data type
That data appears in multiple places (different blocks, pages)
The data is meaningful on its own (like a detail page)
Examples from this project:
Industry: Used in FeaturedIndustries block, Industry detail page, Filter component
Client: Used in Clients carousel, Client testimonials, About page
Team Member: Used in Team grid, Bio pages, Staff directory
Don't create a collection if:
The data only appears in one place
It's just internal configuration (feature flags, settings)
It's content specific to one block
The Process: Four Steps
Building a collection is straightforward:
Define the type based on the data structure
Create example data for development
Export from collections index so blocks can use it
Use in blocks that display the collection
Let's walk through each.
Step 1: Define the Type
Look at what you're modeling. What fields does this entity have?
File: src/types/collections/industry.ts
typescript
importtype { Media } from'@payload-types';
importtype { CTA } from'@/types/blocks';
/**
* Industry Collection
* Represents an industry category (Retail, Healthcare, etc.)
*/exportinterfaceIndustry {
// Core identificationid: number; // Unique identifiertitle: string; // Industry name (e.g., "Retail")slug?: string; // URL slug (e.g., "retail")// Contentdescription?: string; // Short description (for cards)longDescription?: string; // Detailed description (for detail page)// Media & Iconimage?: Media; // Featured image (for cards, detail page)icon?: string; // Lucide icon name (e.g., "ShoppingBag")// Linklink?: CTA; // Link to detail page or related resource// Status & metadata (for Payload compatibility)_status?: 'draft' | 'published';
meta?: {
title?: string;
description?: string;
};
// TimestampscreatedAt: string;
updatedAt: string;
}
Design decisions:
id: number matches Payload conventions and makes references easy
slug is auto-generated (from title) but helpful for URLs
description is short (for card display)
longDescription is detailed (for dedicated detail page)
image is optional but expected when displayed
icon is a Lucide icon name (string), not a component
link uses the reusable CTA type
Status and timestamps prepare for Payload migration
Step 2: Create Example Data
Create realistic example data for development:
File: src/types/collections/industry.ts (add to same file)
typescript
exportconstretailIndustry: Industry = {
id: 1,
title: 'Retail',
slug: 'retail',
description: 'Custom signage for retail storefronts and shopping centers',
longDescription: `Transform your retail space with custom signage solutions.
From storefront displays to interior wayfinding, we create signage
that enhances customer experience and drives foot traffic.`,
image: {
url: 'https://example.com/retail-industry.jpg',
alt: 'Retail storefront with custom signage',
width: 1200,
height: 800,
},
icon: 'ShoppingBag',
link: {
label: 'Explore Retail Solutions',
href: '/industries/retail',
},
_status: 'published',
createdAt: newDate().toISOString(),
updatedAt: newDate().toISOString(),
};
exportconsthealthcareIndustry: Industry = {
id: 2,
title: 'Healthcare',
slug: 'healthcare',
description: 'Professional signage for hospitals and medical facilities',
longDescription: `Healthcare facilities require clear, compliant signage.
We specialize in wayfinding, room identification, and ADA-compliant
signage that meets healthcare standards.`,
image: {
url: 'https://example.com/healthcare-industry.jpg',
alt: 'Hospital hallway with professional signage',
width: 1200,
height: 800,
},
icon: 'Heart',
link: {
label: 'Explore Healthcare Solutions',
href: '/industries/healthcare',
},
_status: 'published',
createdAt: newDate().toISOString(),
updatedAt: newDate().toISOString(),
};
exportconstindustriesData: Industry[] = [
retailIndustry,
healthcareIndustry,
// Add more as needed
];
Why detailed examples:
Shows exactly what each field should contain
Demonstrates real-world data structure
Can be copied and modified for other entries
Documents expected format for future developers
Step 3: Export from Collections Index
Make your collection available to blocks and pages:
importtype { Industry } from'@/types/collections';
import { industriesData } from'@/types/collections';
Step 4: Use in Blocks
Blocks display collections. Update your block type to accept collection data:
File: src/types/blocks/featured-industries.ts
typescript
importtype { Industry } from'@/types/collections';
exportinterfaceFeaturedIndustriesBlock {
blockType: 'featuredIndustries';
template: 'grid' | 'carousel';
title?: string;
selectedIndustries?: Industry[]; // ← Use collection type hereitemsPerView?: number;
}
Now the block knows it displays Industry items. Blocks that display collections should have a field like selectedIndustries, items, or clients containing the collection type.
Collections can reference each other by ID or by including the entire referenced object. For development, include full objects. For Payload, you'd use IDs and resolve them in queries.
File Structure
When you're done creating a collection, you have:
code
src/types/collections/
├─ index.ts ← Exports all collections
├─ industry.ts ← Collection type + examples
├─ client.ts ← Another collection
└─ team-member.ts ← Yet another collection
Each collection file is self-contained but exports from the index for easy access.
Naming Conventions
Type names: Singular (Industry, Client, TeamMember)
Collections (arrays): Plural with "Data" suffix (industriesData, clientsData)
Example items: Describe the item (retailIndustry, johnSmithTeamMember)
File names: kebab-case matching type (industry.ts, team-member.ts)