Skip to content

Add notes about glob()'s normalization of ids in upgrade guides#13704

Open
OverflowCat wants to merge 1 commit intowithastro:mainfrom
OverflowCat:patch-1
Open

Add notes about glob()'s normalization of ids in upgrade guides#13704
OverflowCat wants to merge 1 commit intowithastro:mainfrom
OverflowCat:patch-1

Conversation

@OverflowCat
Copy link
Copy Markdown
Contributor

@OverflowCat OverflowCat commented Apr 9, 2026

Description

This PR updates the documentation to clarify that collection entry IDs are automatically lowercased when migrating legacy content collections to glob(). In legacy content collections, file names with uppercase characters could be used directly as IDs, while glob() normalizes them to kebab-case. This change is currently not clearly documented in the migration guide, which may lead to confusion for users.

getEntry('data', 'testTest') // ❌
getEntry('data', 'testtest') // ✅

Related issues & labels

Would still be useful to have that in the migration guide or content collections docs, as it's not expected.

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 9, 2026

Deploy Preview for astro-docs-2 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit bc345c8
🔍 Latest deploy log https://app.netlify.com/projects/astro-docs-2/deploys/69d7153c2e30a50008ab3bd8
😎 Deploy Preview https://deploy-preview-13704--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@astrobot-houston
Copy link
Copy Markdown
Contributor

astrobot-houston commented Apr 9, 2026

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/guides/upgrade-to/v5.mdx Source changed, localizations will be marked as outdated.
en/guides/upgrade-to/v6.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@OverflowCat OverflowCat changed the title Add notes about glob()'s normalization of ids in v6 upgrade guide Add notes about glob()'s normalization of ids in upgrade guides Apr 9, 2026
@OverflowCat OverflowCat marked this pull request as ready for review April 9, 2026 03:00
Copy link
Copy Markdown
Member

@ArmandPhilippot ArmandPhilippot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I think this can be helpful! I left two suggestions: I think we have a more helpful link and, I'm not quite sure about the current format for the v5 guide.

});
```

Different from content collections, the `glob()` loader normalizes `id`s to kebab-cased slugs by default, so hard-coded `id`s including capital letters (like `getEntry("UpperCase")`) in your code may break. You can pass a custom [`generateID()` helper function](/en/reference/content-loader-reference/#generateid) to override this behavior.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like:

Suggested change
Different from content collections, the `glob()` loader normalizes `id`s to kebab-cased slugs by default, so hard-coded `id`s including capital letters (like `getEntry("UpperCase")`) in your code may break. You can pass a custom [`generateID()` helper function](/en/reference/content-loader-reference/#generateid) to override this behavior.
By default, the `glob()` loader generates an ID by converting all uppercase letters to lowercase. Therefore, you may need to check and update your calls to `getEntry()` or [use the `generateId()` helper to restore the old behavior](/en/guides/content-collections/#defining-custom-ids).
  • Unless I'm mistaken, what has changed is not really the slugs in kebab-case but the identifier in lowercase, so we should probably be more direct in drawing attention to this new behavior.
  • We have an example in the content collections guide to restore the old behavior. So, it might be more helpful to use that link rather than the reference.

1. **Move the content config file**. This file no longer lives within the `src/content/` folder. This file should now exist at `src/content.config.ts`.

2. **Edit the collection definition**. Your updated collection requires a `loader` which indicates both a folder for the location of your collection (`base`) and a `pattern` defining the collection entry filenames and extensions to match. (You may need to update the example below accordingly. You can use [globster.xyz](https://globster.xyz/) to check your glob pattern.) The option to select a collection `type` is no longer available.
2. **Edit the collection definition**. Your updated collection requires a `loader` which indicates both a folder for the location of your collection (`base`) and a `pattern` defining the collection entry filenames and extensions to match. (You may need to update the example below accordingly. You can use [globster.xyz](https://globster.xyz/) to check your glob pattern.) The option to select a collection `type` is no longer available. Different from content collctions, the `glob()` loader normalizes `id`s to a kebab-cased slug by default, so hard-coded `id`s that contain capital letters (like `getEntry("UpperCase")`) in your code may break. You can pass a custom [`generateID()` helper function](/en/reference/content-loader-reference/#generateid) to override this behavior.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step is becoming very long and hard to parse. And, the code snippet below doesn't display generateId().
I wonder if it wouldn't be more readable to use the wording suggested for the v6 upgrade guide and place it below the code snippet.

@ArmandPhilippot ArmandPhilippot added the improve or update documentation Enhance / update existing documentation (e.g. add example, improve description, update for changes) label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improve or update documentation Enhance / update existing documentation (e.g. add example, improve description, update for changes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants