Purpose
Route process plugins are responsible for:- Filtering routes based on criteria (environment, flags, metadata)
- Adding computed properties to routes
- Sorting or reorganizing the route list
- Generating derived routes (pagination, categories, tags)
- Validating route data
- Creating sitemaps or route indexes
Function Signature
Lifecycle
- Router plugins discover and generate routes
- All routes are collected into a single array
- Route process plugins run in priority order (lowest to highest)
- Each plugin receives the full route list
- Each plugin returns a modified route list
- The output of one plugin becomes the input of the next
- The final route list is stored in
scully.routes.json - Routes are rendered using the processed list
Priority System
Route process plugins execute in order based on their priority (lower numbers run first):100 if not specified.
When to Use
Create a route process plugin when you need to:- Filter routes based on environment or feature flags
- Add pagination to a list of routes
- Generate category or tag pages from content metadata
- Sort routes by date, title, or custom criteria
- Validate that all routes have required metadata
- Add computed properties (reading time, related posts)
- Create route hierarchies or breadcrumbs
- Generate sitemap data
Implementation Examples
Basic Route Process Plugin
Filter Unpublished Routes
Sort Blog Posts by Date
Add Reading Time
Generate Pagination Routes
Generate Tag Pages
Validate Required Fields
Changing Plugin Priority
You can change a plugin’s priority after registration:How Routes are Processed
Configuration
Route process plugins are registered globally and run on all builds:Best Practices
- Always return an array: Even if you don’t modify routes, return the input array
- Don’t mutate routes directly: Create new objects with spread operators
- Handle missing data gracefully: Check for
route.dataexistence - Use appropriate priority: Run filters early, enhancements late
- Log important changes: Inform users when routes are filtered or modified
- Performance matters: Process all routes efficiently
- Avoid async I/O in loops: Use
Promise.all()for parallel operations - Document side effects: Clearly document what your plugin does
- Test with large route sets: Ensure scalability
- Be idempotent: Running multiple times should produce same result
Priority Guidelines
- 0-49: Critical early processing (filtering, validation)
- 50-99: Data enrichment (reading files, computing values)
- 100-149: Default processing (sorting, organizing)
- 150-199: Route generation (pagination, tags, categories)
- 200+: Final validation, logging, reporting
Error Handling
Accessing Processed Routes
The final processed route list is stored inscully.routes.json:
Built-in Route Process Plugins
Scully doesn’t include built-in route process plugins by default, but the ecosystem has several:scully-plugin-sitemap: Generates sitemap.xml from routesscully-plugin-rss: Generates RSS feed from routes- Custom plugins for specific use cases
Related
- Router Plugins - Discover and generate routes
- Render Plugins - Process HTML after rendering
- File Handler Plugins - Transform content files

