Skip to Content
Delmare Digital
Guides

Adding to existing projects

Add payload-page-tree to a project that already has pages and folders without changing any live URL until you choose to.

You can add the plugin to a project that already has content. Nothing changes a live URL until you ask for it.

  1. Existing pages keep their slugs. The plugin only generates a slug on create, or on update when the page's folder or segment changes or you explicitly regenerate.
  2. No schema conflicts. pathSegment is optional, so existing folders work without changes.
  3. Migrate when you're ready. Use Regenerate URLs on a folder to rebuild its pages' slugs from the folder structure.

Give folders a segment before regenerating

A folder without a pathSegment adds nothing to its pages' URLs; the folders above it still do. Before 0.4.0, such a folder also dropped every folder above it. Folders get a segment automatically the next time they're saved (generated from the name). Fill in segments for existing folders before you regenerate URLs.

Filling in folder segments

The POST /api/page-tree/migrate endpoint sets pathSegment to the slugified folder name on every folder that has none. It doesn't cascade, so page slugs are kept. Like every tree endpoint it needs a user who passes the access gate and has update access on folders.

It returns { success, message, count, folders }, where folders lists each updated folder's id, name and new pathSegment.

Edit this page on GitHub

On this page