Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Folders

Folders allow you to group documents across collections, and are a great way to organize your content. Folders are built on top of relationship fields, when you enable folders on a collection, Payload adds a hidden relationship field folders, that relates to a folder — or no folder. Folders also have the folder field, allowing folders to be nested within other folders.

The configuration for folders is done in two places, the collection config and the Payload config. The collection config is where you enable folders, and the Payload config is where you configure the global folder settings.

Folder Configuration

On the payload config, you can configure the following settings under the folders property:

1
// Type definition
2
3
type RootFoldersConfiguration = {
4
/**
5
* An array of functions to be ran when the folder collection is initialized
6
* This allows plugins to modify the collection configuration
7
*/
8
collectionOverrides?: (({
9
collection,
10
}: {
11
collection: CollectionConfig
12
}) => CollectionConfig | Promise<CollectionConfig>)[]
13
/**
14
* Ability to view hidden fields and collections related to folders
15
*
16
* @default false
17
*/
18
debug?: boolean
19
/**
20
* The Folder field name
21
*
22
* @default "folder"
23
*/
24
fieldName?: string
25
/**
26
* Slug for the folder collection
27
*
28
* @default "payload-folders"
29
*/
30
slug?: string
31
}
1
// Example usage
2
3
import { buildConfig } from 'payload'
4
5
const config = buildConfig({
6
// ...
7
folders: {
8
debug: true, // optional
9
collectionOverrides: [
10
async ({ collection }) => {
11
return collection
12
},
13
], // optional
14
fieldName: 'folder', // optional
15
slug: 'payload-folders', // optional
16
},
17
})

Collection Configuration

To enable folders on a collection, you need to set the admin.folders property to true on the collection config. This will add a hidden relationship field to the collection that relates to a folder — or no folder.

1
// Type definition
2
3
type CollectionFoldersConfiguration = boolean
1
// Example usage
2
3
import { buildConfig } from 'payload'
4
5
const config = buildConfig({
6
collections: [
7
{
8
slug: 'pages',
9
admin: {
10
folders: true, // defaults to false
11
},
12
},
13
],
14
})
Next

Email Functionality