"No Astro Content Collections found" on existing project #724

Closed
opened 2026-10-05 03:02:16 +02:00 by adam · 9 comments
Owner

So I don't know if it is the same reason, but the issue happened to me on latest Frontmatter and Astro. I however do not get errors in the frontmatter output. Also happens on both npm and pnpm.

Image

My content.config.ts

import { defineCollection, z } from 'astro:content';

import { glob } from 'astro/loaders';

const blog = defineCollection({ 
    loader: glob({ pattern: '**/*.md', base: "./src/content/blog" }),
    schema:({ image }) => z.object({
        title: z.string(),
        description: z.string(),
        createdAt: z.string(),
        updatedAt: z.string(),
        tags: z.array(z.string()),
        image: image(),
        author: z.string().optional(),
        
    }),
});

export const collections = {
    blog,
};

Originally posted by @FantixX in #703

> So I don't know if it is the same reason, but the issue happened to me on latest Frontmatter and Astro. I however do not get errors in the frontmatter output. Also happens on both npm and pnpm. > > ![Image](https://github.com/user-attachments/assets/d8a6518d-4eac-49f6-ba08-15351eef57f2) > > My content.config.ts > > ``` > import { defineCollection, z } from 'astro:content'; > > import { glob } from 'astro/loaders'; > > const blog = defineCollection({ > loader: glob({ pattern: '**/*.md', base: "./src/content/blog" }), > schema:({ image }) => z.object({ > title: z.string(), > description: z.string(), > createdAt: z.string(), > updatedAt: z.string(), > tags: z.array(z.string()), > image: image(), > author: z.string().optional(), > > }), > }); > > export const collections = { > blog, > }; > > ``` _Originally posted by @FantixX in [#703](https://github.com/estruyf/vscode-front-matter/issues/703#issuecomment-2727508443)_ <!-- github-sync-id:2923316386 -->
adam closed this issue 2026-10-05 03:02:17 +02:00
Author
Owner

The script for the content types looks for a config.ts file in the ./src/content folder. That is probably why it doesn't work with your configuration.

The script for the content types looks for a `config.ts` file in the `./src/content` folder. That is probably why it doesn't work with your configuration. <!-- github-comment-id:2729058815 -->
Author
Owner

The script for the content types looks for a config.ts file in the ./src/content folder. That is probably why it doesn't work with your configuration.

Ohh okay, so should I just put this one in src/content and reexport it in src/content.config.ts, so astro picks it up?

> The script for the content types looks for a `config.ts` file in the `./src/content` folder. That is probably why it doesn't work with your configuration. Ohh okay, so should I just put this one in src/content and reexport it in src/content.config.ts, so astro picks it up? <!-- github-comment-id:2729143440 -->
Author
Owner

If you create the file in the src/content/config.ts location, it should work for finding the content collections. Afterwards you can revert it to the original location. I wasn't yet aware that you could have content.config.ts files as well. So will have to test it out and implement an enhancement.

If you create the file in the `src/content/config.ts` location, it should work for finding the content collections. Afterwards you can revert it to the original location. I wasn't yet aware that you could have `content.config.ts` files as well. So will have to test it out and implement an enhancement. <!-- github-comment-id:2730263717 -->
Author
Owner

I have the same issue: content.config.ts under src (Astro 5). src/content/config.ts is still supported, but I don't know when this will be deprecated.

https://docs.astro.build/en/guides/upgrade-to/v5/#legacy-v20-content-collections-api

Additionally, temporary backwards compatibility exists for keeping the content config file in its original location of src/content/config.ts.

collections should always be defined in src/content.config.ts

Not a big issue for me, just testing frontmatter out at the moment (I love the idea though!)

I have the same issue: `content.config.ts` under `src` (Astro 5). `src/content/config.ts` is still supported, but I don't know when this will be deprecated. https://docs.astro.build/en/guides/upgrade-to/v5/#legacy-v20-content-collections-api > Additionally, temporary backwards compatibility exists for keeping the content config file in its original location of src/content/config.ts. > collections should always be defined in src/content.config.ts Not a big issue for me, just testing frontmatter out at the moment (I love the idea though!) <!-- github-comment-id:2778513829 -->
Author
Owner

@sec-ml thanks for the info. We definitely need to work on this one. ☝️ I didn't know it was deprecated.

Is the schema structure the same like in the old fine? If that would be the case, it will be easy to support.

@sec-ml thanks for the info. We definitely need to work on this one. ☝️ I didn't know it was deprecated. Is the schema structure the same like in the old fine? If that would be the case, it will be easy to support. <!-- github-comment-id:2779162159 -->
Author
Owner

I'm still learning as I go with Astro (hadn't looked at creating a collection until this version) so I can't comment on the differences. I did try moving content.config.ts to content/config.ts to see if the Frontmatter picked it up, but it didn't. I guess it depends on how the schema is being validated.

This is my schema - Not actually expecting it to work given some of the custom stuff, just providing as an example.

Got to say, I like the Docs bot, so at least I can manually create a schema:

my astro content collection isn't detected. How do I manually define a schema in the frontmatter config?

🤖 To manually define a schema for your Astro content collection in the Front Matter configuration, you can create a custom data type in the .frontmatter configuration. Here’s how you can do it:

Create a JSON Schema File:
First, you need to create a JSON file that defines the schema for your content collection. This file should be placed in the .frontmatter/config/data/types/ directory. You can create sub-folders to organize your schemas if needed.

For example, if you want to define a schema for a content type called article, you can create a file named article.json in the types directory:

| .frontmatter
| - config
| -- data
| --- types
| ---- article.json
Define the Schema:
In the article.json file, define the schema using JSON. Here is an example schema for an article content type:

{
"$schema": "https://frontmatter.codes/config/data.types.schema.json",
"id": "astro.content.article",
"schema": {
"title": "Article Content Type",
"type": "object",
"properties": {
"title": {
"type": "string",
"title": "Title",
"description": "The title of the article"
},
"author": {
"type": "string",
"title": "Author",
"description": "The author of the article"
},
"date": {
"type": "string",
"format": "date",
"title": "Publication Date",
"description": "The publication date of the article"
},
"content": {
"type": "string",
"title": "Content",
"description": "The main content of the article"
}
}
}
}
Register the Content Folder:
Ensure that the folder containing your Astro content is registered in the Front Matter configuration. You can do this by right-clicking on the folder in Visual Studio Code and selecting Front Matter: Register folder.

Verify the Configuration:
After setting up the schema, you can verify that your configuration is correct by using the diagnostic logging command in Front Matter. This will show you the complete frontmatter.json configuration in a virtual Markdown document.

By following these steps, you can manually define and register a schema for your Astro content collection in Front Matter. This will help you manage your content more effectively within the Visual Studio Code environment.
I'm still learning as I go with Astro (hadn't looked at creating a collection until this version) so I can't comment on the differences. I did try moving `content.config.ts` to `content/config.ts` to see if the Frontmatter picked it up, but it didn't. I guess it depends on how the schema is being validated. [This](https://github.com/sec-ml/nought/blob/main/src/content.config.ts) is my schema - Not actually expecting it to work given some of the custom stuff, just providing as an example. Got to say, I like the Docs bot, so at least I can manually create a schema: > my astro content collection isn't detected. How do I manually define a schema in the frontmatter config? ``` 🤖 To manually define a schema for your Astro content collection in the Front Matter configuration, you can create a custom data type in the .frontmatter configuration. Here’s how you can do it: Create a JSON Schema File: First, you need to create a JSON file that defines the schema for your content collection. This file should be placed in the .frontmatter/config/data/types/ directory. You can create sub-folders to organize your schemas if needed. For example, if you want to define a schema for a content type called article, you can create a file named article.json in the types directory: | .frontmatter | - config | -- data | --- types | ---- article.json Define the Schema: In the article.json file, define the schema using JSON. Here is an example schema for an article content type: { "$schema": "https://frontmatter.codes/config/data.types.schema.json", "id": "astro.content.article", "schema": { "title": "Article Content Type", "type": "object", "properties": { "title": { "type": "string", "title": "Title", "description": "The title of the article" }, "author": { "type": "string", "title": "Author", "description": "The author of the article" }, "date": { "type": "string", "format": "date", "title": "Publication Date", "description": "The publication date of the article" }, "content": { "type": "string", "title": "Content", "description": "The main content of the article" } } } } Register the Content Folder: Ensure that the folder containing your Astro content is registered in the Front Matter configuration. You can do this by right-clicking on the folder in Visual Studio Code and selecting Front Matter: Register folder. Verify the Configuration: After setting up the schema, you can verify that your configuration is correct by using the diagnostic logging command in Front Matter. This will show you the complete frontmatter.json configuration in a virtual Markdown document. By following these steps, you can manually define and register a schema for your Astro content collection in Front Matter. This will help you manage your content more effectively within the Visual Studio Code environment. ``` <!-- github-comment-id:2779456920 -->
Author
Owner

Great, this fixes it for me! My content collections are recognized now (using the Beta version). Copilot to the rescue 🙏

Great, this fixes it for me! My content collections are recognized now (using the Beta version). Copilot to the rescue 🙏 <!-- github-comment-id:2970548936 -->
Author
Owner

Thanks @thomasvochten for verifying.

@FantixX is this working for you too?

Thanks @thomasvochten for verifying. @FantixX is this working for you too? <!-- github-comment-id:2971390032 -->
Author
Owner

Version 10.9.0 just got released with this fix included.

Version 10.9.0 just got released with this fix included. <!-- github-comment-id:3022246060 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#724