Use content collections instead of astro.glob [issue 2945]#3182
Conversation
✅ Deploy Preview for astro-docs-2 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
yanthomasdev
left a comment
There was a problem hiding this comment.
Thanks @donovangomez, that's a lovely contribution. I added a small suggestion for you 🙌
Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>
|
|
||
| #### `Astro.glob()` vs Content Collections | ||
|
|
||
| [Content collections](/en/guides/content-collections/) were introduced in `astro@2.0.0`. It's the best way to work with Markdown and MDX files in an Astro project. If your directory contains only Markdown and MDX files, it's best to use Content collections and the `src/content` directory. |
There was a problem hiding this comment.
Thanks for this @donovangomez!
I’ll let @sarah11918 decide here, but I think we don’t generally tell people what is “best” but try to describe some differences and allow people to decide for themselves. Hard to do in a short paragraph where we don’t want to repeat to much of what’s in the content collections guide itself. Maybe something like this?
| [Content collections](/en/guides/content-collections/) were introduced in `astro@2.0.0`. It's the best way to work with Markdown and MDX files in an Astro project. If your directory contains only Markdown and MDX files, it's best to use Content collections and the `src/content` directory. | |
| [Content collections](/en/guides/content-collections/) provide a `getCollection()` API for loading multiple files instead of `Astro.glob()`. If you are working with Markdown and MDX files, you can store them in the `src/content/` directory to take advantage of content collection features. |
There was a problem hiding this comment.
Thanks @delucis ! My bad that was totally mentioned in the writing guide. I do like the rewrite a lot more, it's more neutral.
There was a problem hiding this comment.
Yup, @delucis' edit is much more in keeping with our docs style. I'm going to adjust it just a bit, to help make it more future-proof (e.g. Markdoc...) but it's absolutely the way to go! 🙌
sarah11918
left a comment
There was a problem hiding this comment.
Thanks for grabbing this issue and adding this very helpful contribution, @donovangomez! 🚀
I've left some suggestions to massage this into docs style. What does everyone think?
|
|
||
| #### `Astro.glob()` vs Content Collections | ||
|
|
||
| [Content collections](/en/guides/content-collections/) were introduced in `astro@2.0.0`. It's the best way to work with Markdown and MDX files in an Astro project. If your directory contains only Markdown and MDX files, it's best to use Content collections and the `src/content` directory. |
There was a problem hiding this comment.
Yup, @delucis' edit is much more in keeping with our docs style. I'm going to adjust it just a bit, to help make it more future-proof (e.g. Markdoc...) but it's absolutely the way to go! 🙌
|
Going to tag in @yan-thomas, @kevinzunigacuellar, @ElianCodes and @delucis in case anyone wants to help refine the text here! 🙌 |
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
|
Finally the checks pass! Sorry for the delay @donovangomez , but GitHub was acting up and then we needed to implement a fix for some of our automated checks. NOW we can finally welcome you to Team Docs, and thanks again for jumping on a much needed issue! 🙌 |
What kind of changes does this PR include?
Description
Closes Don't use Glob with content collections #2945
What does this PR change?
Adds another section: Astro.glob() vs Content collections.
Mention content collections and src/content directory is the way to go for md and mdx.
Did you change something visual? A before/after screenshot can be helpful.

I apologize for my writing lol.