# Source: https://content.nuxt.com/raw/docs/collections/types.md

# Collection Types

> Learn about the two types of collections you can define in Nuxt Content.

In Nuxt Content, you can specify a type for each collection, depending on the intended purpose of the collection files. Collections can be defined as either **page** or **data** types.

For both types, built-in fields are generated. Every collection includes these default fields:

- `id`: Unique content identifier
- `stem`: File path without extension (used for sorting and location)
- `extension`: File extension
- `meta`: Custom fields not defined in the collection schema

## Page type

```ts
defineCollection({
  source: '**/*.md',
  type: 'page'
})
```

<tip>

Use the **page** type if there is a 1-to-1 relationship between content files and pages on your site.

</tip>

### Path generation

Nuxt Content will automatically generate a path for each file in the collection, making it easy to create URL mappings.

Here are examples of generated paths based on file structure:

<table>
<thead>
  <tr>
    <th>
      File
    </th>
    
    <th>
      Path
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        content/index.md
      </code>
    </td>
    
    <td>
      <code>
        /
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        content/about.md
      </code>
    </td>
    
    <td>
      <code>
        /about
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        content/blog/index.md
      </code>
    </td>
    
    <td>
      <code>
        /blog
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        content/blog/hello.md
      </code>
    </td>
    
    <td>
      <code>
        /blog/hello
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        content/1.guide/2.installation
      </code>
    </td>
    
    <td>
      <code>
        /guide/installation
      </code>
    </td>
  </tr>
</tbody>
</table>

<note>

You can use the helper [`queryCollection('COLLECTION').path('PATH')`](/docs/utils/query-collection) to retrieve content by a specific path.

</note>

### Schema Overrides

When you use the **page** type, Nuxt Content generates several standard fields that are commonly used for web pages. These fields provide structure and are **automatically** applied to the collection’s schema:

- `path`: Generated route path
- `title`: Page title
- `description`: Page description
- `seo`: SEO metadata (to be used with Nuxt's `useSeoMeta` composable)
- `body`: Page content parsed as AST
- `navigation`: Page navigation configuration (for [queryCollectionNavigation](/docs/utils/query-collection-navigation))

Here is the corresponding schema applied:

```ts
path: z.string(),
  title: z.string(),
  description: z.string(),
  seo: z.intersection(
    z.object({
      title: z.string().optional(),
      description: z.string().optional(),
      meta: z.array(z.record(z.string(), z.any())).optional(),
      link: z.array(z.record(z.string(), z.any())).optional(),
    }),
    z.record(z.string(), z.any()),
  ).optional().default({}),
  body: z.object({
    type: z.string(),
    children: z.any(),
    toc: z.any(),
  }),
  navigation: z.union([
    z.boolean(),
    z.object({
      title: z.string(),
      description: z.string(),
      icon: z.string(),
    }),
  ]).default(true),
```

<note>

You can override any of these fields by defining them in the collection’s schema.

</note>

## Data type

```ts
defineCollection({
  source: 'authors/**.yml',
  type: 'data'
})
```

The data type is useful for content that doesn't directly correspond to a webpage but instead represents structured data you might want to query and display within your application.

With data collections, you have complete control over the schema, allowing you to define custom structures.

<note>

There's no strict relationship between collection type and file extension. For instance, a **page** collection can use [Markdown](/docs/files/markdown) or [YAML](/docs/files/yaml) or [JSON](/docs/files/json) files, and **data** collections can use any of these formats as well.

</note>

## Ordering Files

For both types, you may want to control the display order in lists. Use numeric prefixes in file and directory names to specify an order. Nuxt Content will use these numbers when ordering content lists.

<note>

Nuxt Content uses alphabetical order for sorting, so if you want to use numerical order, you need to prefix single digit numbers with `0`. For example, without the `0` prefix, `10.foo.md` would come before `2.bar.md`.

</note>

```text [Directory structure]
content/
  1.frameworks/
    1.vue.md
    2.nuxt.md
    ...
  2.examples/
    01.nuxthub.md
    02.vercel.md
    03.netlify.md
    04.heroku.md
    ...
    10.cloudflare.md
    index.md
```

<warning>

Separate number from file name using `.` character. Using any other separator will not work.

</warning>