When I built the archive page of my old site, two kinds of nodes in the photo tree suddenly had to be told apart, and in the file system they looked the same. Without a clear signal, the archive would have listed navigation aids as if they were finished work. My answer was a single boolean in the frontmatter.
The content collection collections_photos was later dropped (see why the photo tree is no content collection). The set: true flag stayed, and in July 2026 it still decided which nodes counted as photo sets.
Two kinds of nodes
A node like travels/asia/ only organises. It groups cities under a region, but I would not point anyone to it as a finished work. A node like travels/asia/chiang-mai/ is a real photo set: curated, dated and able to stand on its own. Both are index.md files in the same hierarchy.
The archive page lists everything published in one timeline: articles, notes, links and now photo collections. It should show things worth coming back to. Travels or Asia next to Chiang Mai would be noise.
The flag
The schema got one more field, set:
const collections_photos = defineCollection({
schema: z.object({
title: z.string(),
description: z.string(),
location: z.string().optional(),
publishDate: z.coerce.date().optional(),
draft: z.boolean().default(false),
coverImage: z.string().optional(),
order: z.number().int().default(0),
set: z.boolean().default(false),
}),
});
It defaults to false, so the existing category nodes needed no change. Only real photo sets carry set: true:
---
title: Chiang Mai
description: Street scenes and quiet moments from Chiang Mai.
location: Chiang Mai, Thailand
publishDate: 2025-10-06T11:04:00+01:00
set: true
---
travels/index.md and asia/index.md stayed untouched: no set, no publishDate. The archive filter needs both conditions, the flag and a publish date:
const photoSets = (
await getCollection(
'collections_photos',
({ data }) => data.set && !data.draft && !!data.publishDate,
)
).map((c) => ({
title: c.data.title,
date: c.data.publishDate!,
url: `/photos/collections/${collectionSlug(c)}`,
type: 'photos' as const,
}));
Why not just check publishDate
Leaf collections already had a publishDate and category nodes did not, so filtering on !!publishDate would have given the same result. But publishDate means "when this was published". Using its presence to mean "this is a real set" gives the field two meanings. It is also a trap: a date added to a category node for some later purpose would silently promote it to the archive.
set: true says what it means. The two fields also answer different questions at different moments. I might create a node and add photos for weeks before it is ready. set declares the intent, publishDate the readiness.
The result
Photo sets appeared in the archive next to articles and notes, grouped by year, with a Photo Collection badge. Category nodes never appeared. New collections stay out until they are marked as a set.
Takeaways
- One boolean that means one thing beats an existing field with a second meaning.
- Default to the safe value: a forgotten flag keeps a node out of the archive instead of promoting it by accident.
data.set && !data.draft && !!data.publishDateis the whole rule in one line, and it reads like the requirement.
- Topic
-
- Static Website A website made of finished HTML files that are built once and then served unchanged. No server code, no database.
- Builds on
-
- Structuring Photos as a Collection Tree How the photos of my old Astro site grew from flat albums into a recursive tree: one catch-all route, photos per node, breadcrumbs and tag pages.
- Uses
-
- Astro Tool for building websites from content such as Markdown. Ships plain HTML by default and only loads JavaScript where it is needed.
- Mentioned in
-
- Building the Photo Stream The photo stream of my old Astro site: JSON sidecars next to each JPG, import.meta.glob, a justified grid and batches revealed on scroll.
- Mentioned
-
- Why the Photo Tree Is No Content Collection Anymore When my old Astro site went bilingual, the photo tree left the content layer: every photo and node needs both languages in one file.
- Tags