#folders in content collections
3 messages · Page 1 of 1 (latest)
Yes, you can use any folder name for your content collection, and the folder name itself does not automatically become part of the URL for your generated pages. In Astro, content collections are stored outside of the src/pages/ directory, and no routes are generated by default for collection items. You define the folder structure (e.g., src/interior-pages/), and then manually create dynamic routes in src/pages/ to map your content entries to whatever URLs you want.
For example, you might have a collection like src/interior-pages/ and define it in your content.config.ts. When generating routes, you use dynamic route files (e.g., src/pages/[...slug].astro) and control the URL structure yourself by mapping the collection entries to the desired URLs in your getStaticPaths or SSR logic. The folder name (interior-pages) is just for organization and does not dictate the URL unless you explicitly use it in your routing logic.
This approach is described in the documentation:
Content collections are stored outside of the
src/pages/directory. This means that no pages or routes are generated for your collection items by default. You will need to manually create a new dynamic route if you want to generate HTML pages for each of your collection entries, such as individual blog posts. Your dynamic route will map the incoming request param (e.g.Astro.params.sluginsrc/pages/blog/[...slug].astro) to fetch the correct entry for each page.
Generating Routes from Content