button Add a features section with icons and descriptions Include a stats section with live data Add a responsive design with modern CSS features
52 lines
1.5 KiB
Markdown
52 lines
1.5 KiB
Markdown
# File-Based Routing
|
||
|
||
FolderWeb's routing is beautifully simple: **your folder structure is your URL structure**. No configuration files, no route definitions, no magic strings.
|
||
|
||
## How It Works
|
||
|
||
When you visit a URL, FolderWeb looks for matching folders and files:
|
||
|
||
```
|
||
/content/
|
||
├── index.md → /
|
||
├── about/
|
||
│ └── index.md → /about/
|
||
└── blog/
|
||
├── 2024-11-01-post/
|
||
│ └── index.md → /blog/post/
|
||
└── index.md → /blog/
|
||
```
|
||
|
||
## Automatic Features
|
||
|
||
**Folder names become URLs** – Create a folder called `projects` and it's instantly available at `/projects/`
|
||
|
||
**Date prefixes are stripped** – `2024-11-01-my-post` becomes `/my-post/` in the URL
|
||
|
||
**Custom slugs via metadata** – Override the default URL with `slug = "custom-url"` in `metadata.ini`
|
||
|
||
**Trailing slashes** – Directories always redirect to include trailing slashes for consistency
|
||
|
||
## Example
|
||
|
||
This very page demonstrates file-based routing! The path is:
|
||
|
||
```
|
||
app/default/content/examples/file-based-routing/index.md
|
||
```
|
||
|
||
Which renders at:
|
||
|
||
```
|
||
/examples/file-based-routing/
|
||
```
|
||
|
||
No routes to define. No configuration to update. Just files and folders.
|
||
|
||
## Benefits
|
||
|
||
- **Intuitive** – If you can navigate folders, you understand the routing
|
||
- **Refactor-friendly** – Moving content means moving folders
|
||
- **No broken links** – URLs match the filesystem
|
||
- **Fast** – No route matching overhead, direct file lookup
|
||
- **Predictable** – What you see is what you get
|