Skip to content

Fix collection items colliding when they share a basename#783

Merged
nicodevs merged 1 commit into
mainfrom
nd/fix-collection-items-same-basename
May 1, 2026
Merged

Fix collection items colliding when they share a basename#783
nicodevs merged 1 commit into
mainfrom
nd/fix-collection-items-same-basename

Conversation

@nicodevs

@nicodevs nicodevs commented May 1, 2026

Copy link
Copy Markdown
Contributor

Closes #674

Issue

Two files in the same collection with the same basename (e.g. _posts/example.md and _posts/foo/example.md) would silently collapse into a single output. The collection is keyed by getFilename(), so the second item overwrites the first.

Solution

Items are now keyed by relativePath/filename when nested. the new method itemKey encapsulates the logic. User-facing access by basename ($siteData->posts->{name}) is unchanged for flat collections. For nested collections, two items that previously masked each other are now both reachable.

@nicodevs nicodevs self-assigned this May 1, 2026
@nicodevs nicodevs force-pushed the nd/fix-collection-items-same-basename branch from 1c19ce6 to 63f3f62 Compare May 1, 2026 18:19
@nicodevs nicodevs merged commit aa1b391 into main May 1, 2026
5 checks passed
@nicodevs nicodevs deleted the nd/fix-collection-items-same-basename branch May 1, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collection items can't have same basename

1 participant