Skip to content

Conversation

@sarah11918
Copy link
Member

@sarah11918 sarah11918 commented Oct 22, 2025

Description (required)

Whew! First draft ready for review!

This PR updates the Content Collections guide so that it describes and differentiates the two types of collections we will have stable in v6: build-time and live. It also creates placeholder (for now) entries in the astro:content module reference page. These will need thorough review and also a check to make sure there's nothing else that needs API reference docs!

This is currently a NWTWWHB draft: content from the current existing Experimental Live Collections reference page has been interwoven with existing (and updated!) content for "regular" build-time collections. This may not be the correct info architecture, and that's OK! This is where we are starting from.

My thoughts throughout this PR:

  • It is important to name and distinguish the two types of collections

  • the two built-in build time loaders (glob() and file()) now have their own, clear, discoverable sections.

  • The natural order of "setting up a collection" is still: define it, add a loader, most likely add a schema; then you're able to query/filter and render; oh, and you probably are going to want dynamic pages based on your entries. So, I've kept that overall structure for now, interleaving Build-time Collection content and Live Collection content. There's a world where Build time and live collections are split out into discrete sections, each following that pattern. However, I think that leads to some duplication and I have added a LOT of internal linking so people can get to where they need to go.

  • Did I say I added a LOT of internal page linking?? One big challenge here is that setting up a simple blog with local Markdown files is much less complicated than needing to build your own live loader. Frankly, there's a crap ton of loader content, but you can't do anything until you have a loader so it feels difficult to offload it to the bottom of the page and just say "go off here to learn about loaders so I can show you the rest of content collections". (see next point)

  • My solution here is the "Types of Collections" section at the beginning with informative, skeleton content that addresses EVERYTHING with links (defining, querying, rendering, generating pages) for each of build and live collections. e.g. As long as you read the short "Build-time content collections", you'll be armed with everything you need to know via direct links to each section you care about.... including a tip to go look at the Astro Blog starter template to see a simple build-time collection in action for a "quick start" approach. (The same is true about the "Live content collections" section: it provides a good overview of the "getting set up" steps with links to identify all the links in the chain. But sorry, you're going to have to figure out how to build a live loader before you can actually do anything.)

  • We now need to differentiate between "build-time SSR" and "live collections", so I've tried to add a few nods to that.

  • Right now, we're showing ALL headings from ## to #####. We won't do that in the final draft. This makes it easy to see the structure while working on it, and for me to easily jump to different sections. But, we'll only have a TOC with ## and ### and I think the way I have it set up, this will look pretty reasonable.

  • Lots of section headings have changed, so probably some link damage to fix up.

Comment threads "resolved" to maybe loop back around to

  • Should there be a "When to use each type of collection" vs the few bullet points at the beginning of each of Build-time and Live Collections?
  • Should section headers be standardized when there is duplication, or distinct to help keep the ideas distinct? (e.g. "Querying build-time collections" vs "Accessing Live Data")
  • Live collections limitations and differences from build time are currently sections at the bottom of the page as "further reading", but linked to from the main entry on live collections for those who need to read further. My concern with putting them up is "making someone get PhD in everything Live Collections" before they get to read more. This feels like info that is OK to just be available/accessible as long as it's clearly linked to as we've done.

For Astro version: 6.0. See astro PR #14550.

@netlify
Copy link

netlify bot commented Oct 22, 2025

Deploy Preview for astro-docs-2 ready!

Name Link
🔨 Latest commit ed51725
🔍 Latest deploy log https://app.netlify.com/projects/astro-docs-2/deploys/690e69014b77fa00083d3b42
😎 Deploy Preview https://deploy-preview-12604--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.

@sarah11918 sarah11918 changed the title remove legacy note, start to rewrite introduction [v6] New content collections guide includes live collections Oct 22, 2025
@astrobot-houston
Copy link
Contributor

astrobot-houston commented Oct 22, 2025

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/cms/keystatic.mdx Source changed, localizations will be marked as outdated.
en/guides/content-collections.mdx Source changed, localizations will be marked as outdated.
en/guides/imports.mdx Source changed, localizations will be marked as outdated.
en/guides/integrations-guide/markdoc.mdx Source changed, localizations will be marked as outdated.
en/guides/integrations-guide/mdx.mdx Source changed, localizations will be marked as outdated.
en/guides/markdown-content.mdx Source changed, localizations will be marked as outdated.
en/guides/media/cloudinary.mdx Source changed, localizations will be marked as outdated.
en/guides/migrate-to-astro/from-create-react-app.mdx Source changed, localizations will be marked as outdated.
en/guides/migrate-to-astro/from-gatsby.mdx Source changed, localizations will be marked as outdated.
en/guides/migrate-to-astro/from-nextjs.mdx Source changed, localizations will be marked as outdated.
en/guides/upgrade-to/v6.mdx Source changed, localizations will be marked as outdated.
en/reference/cli-reference.mdx Source changed, localizations will be marked as outdated.
en/reference/content-loader-reference.mdx Source changed, localizations will be marked as outdated.
en/reference/errors/content-collection-missing-loader.mdx Source changed, localizations will be marked as outdated.
en/reference/errors/file-glob-not-supported.mdx Source changed, localizations will be marked as outdated.
en/reference/errors/legacy-content-config-error.mdx Source changed, localizations will be marked as outdated.
en/reference/modules/astro-content.mdx Source changed, localizations will be marked as outdated.
en/tutorial/6-islands/4.mdx Source changed, localizations will be marked as outdated.
es/guides/media/cloudinary.mdx Localization changed, will be marked as complete.
es/tutorial/6-islands/4.mdx Localization changed, will be marked as complete.
it/tutorial/6-islands/4.mdx Localization changed, will be marked as complete.
ja/guides/integrations-guide/markdoc.mdx Localization changed, will be marked as complete.
ja/guides/migrate-to-astro/from-create-react-app.mdx Localization changed, will be marked as complete.
pt-br/tutorial/6-islands/4.mdx Localization changed, will be marked as complete.
ru/reference/errors/mixed-content-data-collection-error.mdx Localization changed, will be marked as complete.
ru/tutorial/6-islands/4.mdx Localization changed, will be marked as complete.
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.

@sarah11918 sarah11918 added improve or update documentation Enhance / update existing documentation (e.g. add example, improve description, update for changes) merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) 6.0 labels Oct 22, 2025
@sarah11918
Copy link
Member Author

And here we go...
image

@sarah11918
Copy link
Member Author

Pfft... not concerned!

image

@github-actions github-actions bot added the i18n Anything to do with internationalization & translation efforts - ask @YanThomas for help! label Oct 22, 2025
@sarah11918
Copy link
Member Author

This one's for @OliverSpeir and @ArmandPhilippot ! See what you think of the latest reorganization.

I will note that to have higher Build/Live sections means every section is now one heading level deeper, and I don't think we could publish this page without showing h4s now. But, see whether this feels better to you!

(Note: JSON schemas and below is still just the accumulated pile at the end of the page 😆 )

Copy link
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.

I will note that to have higher Build/Live sections means every section is now one heading level deeper, and I don't think we could publish this page without showing h4s now. But, see whether this feels better to you!

Well, I might be biased because I use tables of contents a lot (on all websites), so I don't think displaying h4 is a problem when relevant.
The structure seems clearer to me, and I think it's easier to identify/navigate to the right section! And I haven't noticed too much repeats (e.g. schema), so I think the new organization looks better! Great job!

I left a few comments on sections that haven't been updated, but without suggestions. The new GitHub experience is not so great. 😅

Copy link
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.

I haven't reread everything in details yet, only the most recent commits. But, this seems to be in good shape for me. And I see you've applied some code snippets changes based on HiDeoo feedbacks! 🙌🏽

I'll give another (deeper) look tomorrow! At the moment, I only spotted some oddness in headings.

Co-authored-by: Armand Philippot <[email protected]>
@sarah11918
Copy link
Member Author

you've applied some code snippets changes based on HiDeoo feedbacks!

Yes, the advantage to talking about loaders first, and schema isn't strictly speaking necessary, then I could just remove it from the loader sections!

@ArmandPhilippot
Copy link
Member

I reread everything and I didn't spotted any issue with the organization or the wording, this looks good to me!
The only exception is in "What is a loader" (Content Loader reference): we only talk about build time loaders which can be confusing. I also checked every code snippets in the 3 pages and I noticed some additional fixes.

Because it was easier to create a PR than creating multiple review comments, here's my suggestions: #12685

I also noticed something unclear regarding the import of the loader errors classes, maybe Matt can confirm where they should be imported from.

In two code snippets we were importing LiveCollectionValidationError and LiveEntryNotFoundError from astro:content. When I checked with the experimental flag (v5), they were not available. Intellisense (and I, in the next branch) could find them in astro/content/runtime though. But, looking at the most recent update in the roadmap proposal this should be available from astro/loaders. 😅

Copy link
Member

@yanthomasdev yanthomasdev left a comment

Choose a reason for hiding this comment

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

Is it final boss time?

You can define a **collection** from a set of data that is structurally similar. This can be a directory of blog posts, a JSON file of product items, or any data that represents multiple items of the same shape.

Collections stored locally in your project or on your filesystem can have entries of Markdown, MDX, Markdoc, YAML, TOML, or JSON files:
A content collection is a set of related, structurally-identical data. This data can be stored in one or several files locally (e.g. a folder of individual Markdown files of blog posts, a single JSON file of product descriptions) or fetched from remote sources such as a database, CMS or API endpoint. Each member of the collection is called an entry.
Copy link
Member

Choose a reason for hiding this comment

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

no hyphen after a -ly word + comma nit

Suggested change
A content collection is a set of related, structurally-identical data. This data can be stored in one or several files locally (e.g. a folder of individual Markdown files of blog posts, a single JSON file of product descriptions) or fetched from remote sources such as a database, CMS or API endpoint. Each member of the collection is called an entry.
A content collection is a set of related, structurally identical data. This data can be stored in one or several files locally (e.g. a folder of individual Markdown files of blog posts, a single JSON file of product descriptions) or fetched from remote sources such as a database, CMS, or API endpoint. Each member of the collection is called an entry.


- You have only one or a small number of different content pages. Consider [making individual page components](/en/basics/astro-pages/) such as `src/pages/about.astro` with your content directly instead.
- You are displaying files that are not processed by Astro, such as PDFs. Place these static assets in the [`public/` directory](/en/basics/project-structure/#public) of your project instead.
- Your data source has its own SDK/client library for imports that is incompatible with or does not offer a content loader and you prefer to use it directly.
Copy link
Member

Choose a reason for hiding this comment

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

comma nit

Suggested change
- Your data source has its own SDK/client library for imports that is incompatible with or does not offer a content loader and you prefer to use it directly.
- Your data source has its own SDK/client library for imports that is incompatible with or does not offer a content loader, and you prefer to use it directly.


## Types of collections

**[Build-time content collections](#build-time-content-collections)** are updated at build time and data is saved to a storage layer. This provides excellent performance for most content, but may not be suitable for frequently updating data sources requiring up-to-the-moment data freshness such as live stock prices.
Copy link
Member

Choose a reason for hiding this comment

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

comma nit

Suggested change
**[Build-time content collections](#build-time-content-collections)** are updated at build time and data is saved to a storage layer. This provides excellent performance for most content, but may not be suitable for frequently updating data sources requiring up-to-the-moment data freshness such as live stock prices.
**[Build-time content collections](#build-time-content-collections)** are updated at build time, and data is saved to a storage layer. This provides excellent performance for most content, but may not be suitable for frequently updating data sources requiring up-to-the-moment data freshness, such as live stock prices.


Both kinds of collections can exist in the same project, so you can always choose the best type of collection for each individual data source. For example, a build-time collection can manage product descriptions, while a live collection can manage content inventory.

Both types of collections use similar APIs (e.g. `getCollection()` and `getLiveCollection()`) so that working with collections will feel familiar no matter which one you choose, while still ensuring that you always know which type of collection you are working with.
Copy link
Member

Choose a reason for hiding this comment

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

comma nit

Suggested change
Both types of collections use similar APIs (e.g. `getCollection()` and `getLiveCollection()`) so that working with collections will feel familiar no matter which one you choose, while still ensuring that you always know which type of collection you are working with.
Both types of collections use similar APIs (e.g. `getCollection()` and `getLiveCollection()`), so that working with collections will feel familiar no matter which one you choose, while still ensuring that you always know which type of collection you are working with.


## TypeScript configuration for collections

Content collections rely on TypeScript to provide Zod validation, Intellisense and type checking in your editor. If you are not extending one of Astro's `strict` or `strictest` TypeScript settings, you will need to ensure the following `compilerOptions` are set in your `tsconfig.json`:
Copy link
Member

Choose a reason for hiding this comment

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

retroactive comma nit

Suggested change
Content collections rely on TypeScript to provide Zod validation, Intellisense, and type checking in your editor. If you are not extending one of Astro's `strict` or `strictest` TypeScript settings, you will need to ensure the following `compilerOptions` are set in your `tsconfig.json`:


<p><Since v="6.0.0" /></p>

Live content collections offer APIs to configure, query and render fresh, up-to-the-moment live data from remote sources.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Live content collections offer APIs to configure, query and render fresh, up-to-the-moment live data from remote sources.
Live content collections offer APIs to configure, query, and render fresh, up-to-the-moment live data from remote sources.


When you define a schema, it will take precedence over the [live loader’s types](/en/reference/content-loader-reference/#live-loader-api) when you query the collection.

[See the `Content Collection` guide](/en/guides/content-collections/#using-zod-schemas-with-live-collections) for example usage.
Copy link
Member

Choose a reason for hiding this comment

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

Content Collection in backticks feels wrong since we use it for indicating code parts, plus we tend to refer to the usual guide title (in plural, in this case). I see this is replicated all over this page, but in all other pages, we write it as "See the Content Collections guide".

I guess it makes sense to change all the instances here.

<Since v="6.0.0" />
</p>

A function that retrieves a single live collection entry by collection name and an optional filter either as an `id` string or as a type-safe object.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
A function that retrieves a single live collection entry by collection name and an optional filter either as an `id` string or as a type-safe object.
A function that retrieves a single live collection entry by collection name and an optional filter, either as an `id` string or as a type-safe object.

**Type:** `(context: LoadCollectionContext<TCollectionFilter>) => Promise<LiveDataCollection<TData> | { error: TError; }>`
</p>

Defines a method to load a collection of entries. This function receives a [context object](#loadcollectioncontext) containing an optional `filter` property and must return a the data associated to this collection or the errors.
Copy link
Member

Choose a reason for hiding this comment

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

typo + nit

Suggested change
Defines a method to load a collection of entries. This function receives a [context object](#loadcollectioncontext) containing an optional `filter` property and must return a the data associated to this collection or the errors.
Defines a method to load a collection of entries. This function receives a [context object](#loadcollectioncontext) containing an optional `filter` property and must return the data associated with this collection or the errors.

**Type:** `(context: LoadEntryContext<TEntryFilter>) => Promise<LiveDataEntry<TData> | undefined | { error: TError; }>`
</p>

Defines a method to load a single entry. This function receives a [context object](#loadentrycontext) containing a `filter` property and returns either the data associated to the requested entry, `undefined` when the entry cannot be found, or the errors.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Defines a method to load a single entry. This function receives a [context object](#loadentrycontext) containing a `filter` property and returns either the data associated to the requested entry, `undefined` when the entry cannot be found, or the errors.
Defines a method to load a single entry. This function receives a [context object](#loadentrycontext) containing a `filter` property and returns either the data associated with the requested entry, `undefined` when the entry cannot be found, or the errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.0 i18n Anything to do with internationalization & translation efforts - ask @YanThomas for help! improve or update documentation Enhance / update existing documentation (e.g. add example, improve description, update for changes) merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants