Overview
The Content Folder plugin:- Automatically discovers content files in specified directories
- Generates routes based on file structure
- Supports multiple file formats (Markdown, MDX, AsciiDoc, etc.)
- Handles nested directories
- Extracts frontmatter metadata from files
- Supports custom slugs and multiple slug variations
Configuration
Configure the plugin in yourscully.config.ts:
Configuration Options
The folder path containing your content files, relative to the project root.
Must be set to
contentFolder to use this plugin.Usage Examples
Basic Blog Setup
Create a blog with posts in ablog folder:
/blog/first-post/blog/second-post/blog/third-post
Nested Directories
The plugin automatically handles nested directory structures: Folder structure:/docs/getting-started/docs/guides/installation/docs/guides/configuration/docs/api/reference
Custom Slugs
Override the default slug using frontmatter:/blog/awesome-post instead of using the filename.
Multiple Slugs
Create multiple routes for the same content:/blog/product-launch-2024/blog/new-product/blog/product-announcement
Multiple Content Folders
Configure different content types:File Format Support
The plugin works with any file format that has a registered file handler plugin:- Markdown (
.md) - Built-in support - MDX (
.mdx) - Built-in support - AsciiDoc (
.adoc) - With plugin - Org-mode (
.org) - With plugin
Files without a registered file handler plugin will be skipped with a warning message.
Frontmatter Metadata
All frontmatter from your content files is extracted and made available as route data:ScullyRoutesService.
How It Works
- Directory Scanning: The plugin recursively scans the configured folder
- File Validation: Each file is checked for:
- Non-empty content
- Supported file extension
- Registered file handler plugin
- Metadata Extraction: Frontmatter is parsed from each file
- Route Generation: Routes are created based on:
- File path and name
- Custom
slugfrom frontmatter - Additional
slugsarray if provided
- Route Registration: All routes are registered with their metadata
Slug Generation
The plugin generates slugs automatically:- Spaces are replaced with underscores
- Forward slashes are replaced with underscores
- Question marks are replaced with underscores
When to Use
Use the Content Folder plugin when you:- Need to build a blog or documentation site
- Want file-based routing for content
- Have markdown or MDX files to convert to pages
- Need automatic route generation from file structure
- Want to manage content separately from code
Error Handling
The plugin handles common issues gracefully: Empty files:Pre-publish Slugs
If your content uses a pre-publish workflow, only the primary slug will be used, and theslugs array will be ignored.
Related
JSON Plugin
Generate routes from JSON APIs
Router Plugin
Default router plugin for static routes

