Plugins Overview
Scully’s plugin system is the foundation of its extensibility, allowing you to customize and control every aspect of the static site generation process. Whether you need to fetch dynamic routes, transform HTML content, or execute custom logic at specific points in the build lifecycle, plugins provide the mechanism to do so.What are Scully Plugins?
A Scully plugin is a function that returns a promise (or an async function) that integrates with Scully’s rendering pipeline. Plugins allow you to:- Discover and generate routes dynamically from data sources
- Transform rendered HTML content
- Handle different file types (Markdown, AsciiDoc, etc.)
- Execute custom logic before or after the build process
- Integrate with external services and APIs
Plugin Philosophy
Scully’s plugin architecture is designed with several key principles: Composability: Plugins can be combined and chained together to create complex transformations and workflows. Lifecycle Integration: Plugins hook into specific points in Scully’s build process, giving you precise control over when your code executes. Graceful Error Handling: When a plugin fails, Scully handles it gracefully. You can control whether Scully continues rendering or stops on error using the--pluginsError=false command-line option.
Performance Monitoring: Scully automatically gathers timing data from every plugin execution, helping you identify performance bottlenecks.
Plugin Categories
Scully organizes plugins into three main categories:Built-in Plugins
Scully comes with a comprehensive set of built-in plugins that handle common tasks:contentFolder: Discovers and renders content from markdown and AsciiDoc filesjson: Fetches route data from JSON endpointsmd: Processes Markdown files with syntax highlightingseoHrefOptimise: Optimizes href attributes for SEOflashPrevention: Prevents flash of unstyled content
Community Plugins
The Scully community has created numerous plugins for specialized tasks:@gammastream/scully-plugin-sitemap: Generates XML sitemapsscully-plugin-toc: Creates table of contents@scullyio/scully-plugin-minify-html: Minifies HTML outputscully-plugin-lazy-images: Implements lazy loading for images@notiz/scully-plugin-rss: Generates RSS feeds
Custom Plugins
You can create your own plugins to meet specific requirements. Custom plugins follow the same patterns as built-in plugins and can be easily registered and reused across projects.Plugin Types
Scully provides eleven distinct plugin types, each serving a specific purpose in the build pipeline:| Plugin Type | Purpose | Execution Point |
|---|---|---|
beforeAll | Execute tasks before Scully starts processing | Before any processing begins |
router | Discover and generate routes from data sources | During route discovery |
routeProcess | Transform the collected route array | After routes are discovered |
routeDiscoveryDone | Execute logic after all routes are collected | After route discovery completes |
fileHandler | Process different file types (MD, ADOC, etc.) | During content rendering |
postProcessByDom | Transform HTML using DOM manipulation | After initial render |
postProcessByHtml | Transform HTML as string | After DOM processing |
allDone | Execute tasks after all rendering completes | After all routes are rendered |
enterprise | Custom enterprise-level integrations | Variable |
scullySystem | System-level plugins for core functionality | Variable |
render | Transform rendered HTML (deprecated) | Use postProcessByHtml instead |
Quick Start Example
Here’s a simple example of using plugins in yourscully.config.ts:
Error Handling
Scully’s plugin system includes robust error handling:- By default, plugin errors stop the build process
- Use
--pluginsError=falseto continue rendering even when plugins fail - All plugin errors are logged with detailed information
- Errors include the plugin name, type, and route being processed
Performance Tracking
Scully automatically tracks the performance of every plugin execution:- Each plugin invocation is measured using
performance.mark() - Timing data helps identify slow plugins
- Performance metrics are available in Scully’s output
Next Steps
To dive deeper into Scully’s plugin system:- Plugin System Architecture - Learn how plugins are registered, discovered, and executed
- Plugin Types - Detailed documentation for each plugin type
- Creating Custom Plugins - Build your own plugins
- Built-in Plugins - Explore what’s included
- Community Plugins - Discover community contributions

