Type something to search...

Working with Collections

Working with Collections

Difficulty: Intermediate | Time: 15-20 minutes

This guide explains Astrolock’s collection system and how to use it effectively for organizing audio, image, video, and text content.

What are Collections?

Collections are groups of related content. Astrolock has two types:

Built-in Collections

  1. Blog - Traditional blog posts
  2. Authors - Author profiles and bios

These exist in every Astrolock site.

Media Collections

User-defined collections for different media types:

  • Audio - Music, mixes, podcasts, recordings
  • Image - Photos, galleries, artwork
  • Video - Tutorials, vlogs, films

You define these during bootstrap or add them later.

Why Collections?

Collections provide:

  • Organization: Keep related content together
  • Type Safety: Audio collections expect audio files
  • URL Structure: Clean URLs like /mixes/summer-2025
  • Flexibility: Create ANY type of media collection
  • Scalability: Manage hundreds of items per collection

Creating Collections

During Bootstrap

When you run astrolock init, you’re asked:

? Create a media collection (Y/n): y

Then for each collection:

? Choose type (1-3):
  1) Audio (MP3, WAV, etc.)
  2) Image (JPG, PNG, etc.)
  3) Video (MP4, etc.)

? Collection name (URL-friendly): mixes
? Display name: DJ Mixes
? File extension: .mp3
? Enable genres (Y/n): y

After Bootstrap

Add collections anytime by editing .astrolock/astrolock.yaml:

collections:
  mixes:
    displayName: "DJ Mixes"
    contentType: "audio"
    defaults:
      contentExtension: "mp3"
    features:
      genres: true
      archive: true

After adding a collection, restart the development server to see your changes.

Collection Types

Audio Collections

Use For:

  • DJ mixes
  • Podcasts
  • Music tracks
  • Sound recordings
  • Radio shows

Example:

collections:
  podcasts:
    displayName: "Podcast Episodes"
    contentType: "audio"
    defaults:
      contentExtension: "mp3"

Media Location:

public/audio/content/podcasts/

Image Collections

Use For:

  • Photo galleries
  • Portfolios
  • Artwork
  • Event photos
  • Product images

Example:

collections:
  galleries:
    displayName: "Photo Galleries"
    contentType: "images"
    defaults:
      contentExtension: "jpg"

Media Location:

public/images/content/galleries/

Video Collections

Use For:

  • Tutorials
  • Vlogs
  • Documentaries
  • Product demos
  • Performances

Example:

collections:
  tutorials:
    displayName: "Video Tutorials"
    contentType: "video"
    defaults:
      contentExtension: "mp4"

Media Location:

public/video/content/tutorials/

Naming Collections

Collection Name (Internal)

This is the URL-safe name:

Rules:

  • Lowercase only
  • No spaces (use hyphens)
  • Letters, numbers, hyphens only
  • Used in URLs
  • Used in directory names

Good Examples:

  • mixes
  • photo-galleries
  • dj-sets
  • tutorials

Bad Examples:

  • DJ Mixes (uppercase, spaces)
  • my_gallery (underscores)
  • 2024-photos (starts with number)

Display Name

This is the human-readable name:

Rules:

  • Any characters allowed
  • Used in navigation
  • Used in page titles
  • Can include spaces, capitals

Examples:

  • “DJ Mixes”
  • “Photo Galleries”
  • “Video Tutorials”
  • “My Awesome Podcasts”

Viewing Collections

Check Your Collections

View your collections configuration in .astrolock/astrolock.yaml:

cat .astrolock/astrolock.yaml

Example:

collections:
  # Your collections
  mixes:
    displayName: "DJ Mixes"
    contentType: "audio"
    defaults:
      author: "DJ Awesome"
      contentExtension: "mp3"
    features:
      genres: true

  galleries:
    displayName: "Photo Galleries"
    contentType: "images"
    defaults:
      author: "Photographer"
      contentExtension: "jpg"

Working with Collections

Creating Items

# Create in any collection
astrolock content <collection-name> "Item Title"

# Examples:
astrolock content mixes "Summer Mix"
astrolock content galleries "Trip Photos"
astrolock content tutorials "How to DJ"

Listing Items

# List specific collection
astrolock list mixes

# List all collections
astrolock list

# Show drafts
astrolock list mixes --drafts

Collection Structure

Each collection has:

content/
└── [collection-name]/
    ├── -index.md           # Collection index page
    └── [item-slug].md      # Individual items

public/
└── [media-type]/
    └── content/
        └── [collection-name]/
            └── [media-files]

Example for “mixes” collection:

content/
└── mixes/
    ├── -index.md
    ├── summer-mix-2025.md
    └── winter-vibes.md

public/
└── audio/
    └── content/
        └── mixes/
            ├── summer-mix-2025.mp3
            └── winter-vibes.mp3

Collection Features

Genres

If you enabled genres for a collection, items can have:

---
title: "Summer Mix"
genres: ["house", "techno", "deep-house"]
---

This enables:

  • Genre browsing pages
  • Genre-based filtering
  • Automatic genre archives

Categories

All collections support categories:

---
categories: ["live-sets", "studio-mixes"]
---

Tags

All collections support tags:

---
tags: ["summer", "2025", "chill"]
---

URL Structure

Collections create clean URL structures:

Collection Index

/[collection-name]/

Examples:

  • /mixes/
  • /galleries/
  • /tutorials/

Individual Items

/[collection-name]/[item-slug]/

Examples:

  • /mixes/summer-mix-2025/
  • /galleries/iceland-trip/
  • /tutorials/intro-to-djing/

Categories

/[collection-name]/categories/[category]/

Example:

  • /mixes/categories/house/

Tags

/[collection-name]/tags/[tag]/

Example:

  • /mixes/tags/2025/

Genres (if enabled)

/[collection-name]/genres/[genre]/

Example:

  • /mixes/genres/techno/

Best Practices

1. Choose Meaningful Names

Collections appear in URLs:

Good:

/mixes/summer-vibes/
/photo-galleries/iceland/

Avoid:

/stuff/thing123/
/collection1/item/

2. One Media Type Per Collection

Don’t mix media types:

Good:

  • mixes (audio only)
  • galleries (images only)
  • tutorials (video only)

Avoid:

  • media (mixed audio/video/images)

3. Use Descriptive Display Names

Display names appear in navigation:

Good:

  • “DJ Mix Archive”
  • “Photography Portfolio”
  • “Video Tutorials”

Avoid:

  • “Collection 1”
  • “Stuff”
  • “Media”

4. Plan Your Structure

Think about how users will browse:

By Type:

  • mixes
  • live-sets
  • studio-recordings

By Topic:

  • house-music
  • techno-mixes
  • chill-sets

5. Use Genres Wisely

Enable genres for music, disable for others:

Enable for:

  • Music collections (mixes, tracks)
  • Podcasts (by topic)

Disable for:

  • Photos (use categories instead)
  • Videos (use categories instead)

Common Collection Setups

DJ/Music Site

collections:
  mixes:
    displayName: "DJ Mixes"
    contentType: "audio"
    defaults:
      contentExtension: "mp3"
    features:
      genres: true

  live-sets:
    displayName: "Live Sets"
    contentType: "audio"
    defaults:
      contentExtension: "mp3"
    features:
      genres: true

  tracks:
    displayName: "Original Tracks"
    contentType: "audio"
    defaults:
      contentExtension: "mp3"
    features:
      genres: true

Photography Site

collections:
  portraits:
    displayName: "Portrait Photography"
    contentType: "images"
    defaults:
      contentExtension: "jpg"
    features:
      genres: false

  landscapes:
    displayName: "Landscape Photography"
    contentType: "images"
    defaults:
      contentExtension: "jpg"
    features:
      genres: false

  events:
    displayName: "Event Photography"
    contentType: "images"
    defaults:
      contentExtension: "jpg"
    features:
      genres: false

Podcast Site

collections:
  episodes:
    displayName: "Podcast Episodes"
    contentType: "audio"
    defaults:
      contentExtension: "mp3"
    features:
      genres: true

  bonus:
    displayName: "Bonus Content"
    contentType: "audio"
    defaults:
      contentExtension: "mp3"
    features:
      genres: false

Multi-Media Creator

collections:
  mixes:
    displayName: "DJ Mixes"
    contentType: "audio"
    defaults:
      contentExtension: "mp3"
    features:
      genres: true

  photos:
    displayName: "Photography"
    contentType: "images"
    defaults:
      contentExtension: "jpg"
    features:
      genres: false

  tutorials:
    displayName: "Video Tutorials"
    contentType: "video"
    defaults:
      contentExtension: "mp4"
    features:
      genres: false

Troubleshooting

Can’t find collection

# View your collections configuration
cat .astrolock/astrolock.yaml

Wrong media type

If you created a collection with wrong media type:

  1. Edit .astrolock/astrolock.yaml collections section
  2. Change contentType field
  3. Move media files to correct directory

Collection not showing

  1. Check .astrolock/astrolock.yaml syntax (must be valid YAML)
  2. Ensure directory exists in content/
  3. Run astrolock build to rebuild the site

Next Steps