Configuration
Every pageTreePlugin option — collections, folder slug, segment field names, access, admin view, buildSlug and folder customisation.
pageTreePlugin() takes one optional options object. Every option has a default, so pageTreePlugin() on its own is a complete setup.
pageTreePlugin({
// Collections to add folder-based slugs to (default: ['pages', 'posts'])
collections: ['pages', 'posts'],
// Folder collection slug (default: 'payload-folders')
folderSlug: 'payload-folders',
// Field name for the folder path segment (default: 'pathSegment')
segmentFieldName: 'pathSegment',
// Field name for the page segment (default: 'pageSegment')
pageSegmentFieldName: 'pageSegment',
// Disable plugin hooks while keeping the schema (default: false)
disabled: false,
// Gate for the /api/page-tree/* endpoints (default: any authenticated user)
access: ({ req }) => req.user?.role === 'admin',
// Admin view
adminView: {
enabled: true, // Show the tree view (default: true)
path: '/page-tree', // Admin path for the tree view (default: '/page-tree')
navLabel: 'Page Tree', // Nav group label for the tree link (default: 'Page Tree')
},
// Custom slug builder (replaces folderPath/pageSegment)
buildSlug: ({ pageSegment }) => pageSegment,
// Customise the folders collection (access control, extra fields, ...)
customizeFolderCollection: (collection) => collection,
})Options
Prop
Type
Details: Access control · Custom slugs · Organization scoping.
Choosing collections
The plugin defaults to ['pages', 'posts'] but only manages the collections that exist in your config. If you only have pages, posts is ignored. Pass your own list to manage other collections:
pageTreePlugin({
collections: ['pages', 'articles', 'landing-pages'],
})When a configured collection is missing, the plugin logs [payload-page-tree] Collections not found: …. That usually means another plugin creates the collection after page-tree runs. See Plugin order.
Custom segment field names before 0.4.0
Before 0.4.0, the cascade, tree create, migrate, Edit URL, URL restore and segment checks read the default pathSegment and pageSegment names. On those versions keep segmentFieldName and pageSegmentFieldName at their defaults. From 0.4.0 every path uses your configured names.

