Content collections in Astro make it easier to manage Markdown or MDX content by organizing the markdown files into meaningful collections.
Before we move away from using markdown files and switch over to feeding the Astro site content from our Craft CMS project, let’s look at a new feature in Astro 2: Content Collections.
Content collections in Astro make it easier to manage Markdown or MDX content by organizing the markdown files into meaningful collections (think like a Section in Craft CMS) and validating the data in the frontmatter via Typescript.
One of the challenges of writing with markdown is that the content organization can get messy with a sea of markdown files and no organization or way to query them easily. Astro’s Content Collections tries to make that a better developer and authoring experience.
Content collections live inside of the content
directory, and any markdown or MDX file stored in that directory — or one of its subdirectories — will be part of a collection. The content
directory is a special directory and is required to use Content Collections.
For the real estate marketing site, we’re going to create a news content collection to house the Market News posts.
Let’s get started using Content Collections!
Astro Quick-Start Guide is made up of the following videos: