Create, configure, and organize your content collections
Collections are configured in your .astrolock/astrolock.yaml file.
Creating a Collection
Edit .astrolock/astrolock.yaml and add your collection under the collections section:
collections:
# Your collections
blog:
displayName: "Blog"
contentType: "text"
defaults:
author: ""
ctaText: "Read more"
features:
archive: true
# Add your new collection here
podcast:
displayName: "Podcast"
contentType: "audio"
defaults:
author: "Your Name"
contentExtension: "mp3"
ctaText: "Read more"
features:
archive: false
Tip
Collection names should be lowercase with hyphens (e.g., photo-gallery,
podcast-episodes). These names become part of your URLs:
/photo-gallery/my-post
After Adding a Collection
Once you’ve added a collection to .astrolock/astrolock.yaml:
-
Create the content directory:
mkdir -p content/[collection-name] -
Restart the dev server to pick up the new collection:
# Stop the current server (Ctrl+C) astrolock write -
Add content using the CLI:
astrolock content [collection-name] "My First Post"
Collection Configuration
Collections are defined in the collections section of .astrolock/astrolock.yaml:
collections:
defaults:
author: "unknown"
contentType: "text"
theme: "default"
blog:
displayName: "Blog"
contentType: "text"
features:
archive: true
Collection Options
| Option | Description | Example |
|---|---|---|
displayName | Shown in navigation | "DJ Mixes" |
contentType | Content type | "text", "audio", "images", "video" |
features | Enable collection features | See below |
defaults | Default values for content | { "contentExtension": ".mp3" } |
Features
Enable optional features per collection:
blog:
displayName: "Blog"
contentType: "text"
features:
archive: true
indexStyle: "content"
| Feature | Values | Default | Description |
|---|---|---|---|
archive | true / false | false | Date-based browsing (year/month) |
indexStyle | posts / content / portfolio | posts | How to present the index page for the collection |
Info
See Collections Configuration Reference for all options.
Content Folders
Each collection has a content folder:
content/
├── blog/ # Blog posts
├── mixes/ # Audio files
├── gallery/ # Images
└── videos/ # Video content
Media files go in the public folder:
public/
├── audio/content/mixes/ # Audio files
├── images/content/gallery/ # Image files
└── video/content/videos/ # Video files
Adding to Navigation
Collections appear in navigation automatically. To customize the menu, edit .astrolock/astrolock.yaml:
{
"main": [
{ "name": "Blog", "url": "/blog/" },
{ "name": "Mixes", "url": "/mixes/" }
]
}
Info
See Menu Configuration for full options.
Removing a Collection
- Remove from
.astrolock/astrolock.yamlcollections section - Delete the content folder (
content/{collection}/) - Delete media files (
public/{type}/content/{collection}/) - Update navigation in
.astrolock/astrolock.yamlif needed
Next Steps
- Learn about Text Collections for blogs and articles
- Explore Audio Collections for music content
- Set up Image Collections for galleries
- See Collections Configuration Reference for all options