<collection-item> tag allows you to display entries from a collection on your pages. Collections are reusable content sets (like testimonials, FAQs, features, etc.) that you can manage centrally and display dynamically.
Overview
Collections are perfect for:- Testimonials and reviews
- FAQ sections
- Feature lists
- Team member profiles
- Case studies
- Product benefits
- Any repeating content structure
Basic Usage
Simple Collection Display
With Styling
Attributes
Required Attributes
code
The collection code that identifies which collection to display.
Format: Any string that matches your collection code
Example:
Optional Attributes
id
Element ID applied to each collection entry wrapper.
Example:
Collection Placeholders
Within the<collection-item> template, use {$field_name} to access collection entry fields.
Placeholder Format
Format:{$field_name}
The $ prefix indicates this is a collection field placeholder.
Common Fields
Collection fields depend on how your collection is structured. Common examples include:{$title}- Entry title{$content}- Main content{$description}- Description text{$author}- Author name{$image_url}- Image URL{$name}- Name field{$email}- Email field{$rating}- Rating value{$date}- Date field
Example with Multiple Fields
Complete Examples
Testimonials Collection
FAQ Collection
Features Collection
Team Members Collection
Styling Collections
CSS Grid Layout
Flexbox Layout
How It Works
- Collection Lookup: The system finds the collection by the
codeattribute - Entry Retrieval: All entries from that collection are retrieved
- Template Rendering: For each entry, the template is rendered
- Placeholder Replacement: Collection placeholders (
{$field_name}) are replaced with entry data - Output: Each entry is wrapped in a
<div>with the specifiedid(if provided)
Managing Collections
Collections are managed in your dashboard:- Create Collection: Go to Collections → Create Collection
- Define Fields: Set up the fields your collection entries will have
- Add Entries: Add individual entries to your collection
- Use Code: Use the collection code in your
<collection-item>tags
Collection Structure
When creating a collection, you define:- Collection Code: The identifier used in
code="..."attribute - Fields: Custom fields for each entry (title, content, image, etc.)
- Entries: Individual items in the collection
Best Practices
Content Organization
- Logical Grouping: Group related content into collections
- Consistent Structure: Keep entry fields consistent within a collection
- Reusable Content: Use collections for content you’ll display in multiple places
Template Design
- Responsive: Design templates that work on all devices
- Consistent Styling: Keep styling consistent across entries
- Flexible Layout: Design templates that work with varying content lengths
Performance
- Limit Entries: Don’t create collections with hundreds of entries if you only need a few
- Optimize Images: Ensure collection images are optimized
- Cache Considerations: Collections are rendered server-side for performance
Troubleshooting
No Entries Displaying
Possible Causes:- Collection code doesn’t exist
- Collection has no entries
- Collection code is misspelled
- Verify the collection code in your dashboard
- Check that the collection has entries
- Ensure the
codeattribute matches exactly (case-sensitive)
Placeholders Not Replacing
Issue: Placeholders show as literal text (e.g.,{$title})
Solutions:
- Check placeholder spelling (case-sensitive)
- Ensure you’re using
{$field_name}format with$prefix - Verify the field exists in your collection structure
- Check that entries have values for those fields
Missing Fields
Issue: Some fields are empty Solutions:- Verify the field name matches your collection structure
- Check that entries have values for those fields
- Ensure field names are spelled correctly (case-sensitive)
Related Documentation
- Product Item Tag - Display product listings
- Page Variables - Use variables and placeholders
- Containers - Dynamic content containers