File-Based Routing
Wordless uses the filesystem as its source of truth for routing. Every URL path maps directly to a file or folder, eliminating the need for route configuration files and keeping your site structure transparent and intuitive.
Core Concept
There is a 1-to-1 relationship between URLs and files:
| URL | File |
|---|---|
/ | content/index.php |
/en | content/en/index.php |
/en/about | content/en/about.php |
/en/features | content/en/features/index.php |
/en/features/file-based-routing | content/en/features/file-based-routing.php |
/es/acerca | content/es/acerca.php |
How Resolution Works
When a request for /blog/hello-world arrives, the router:
- Checks for
content/blog/hello-world.php(file match) - If not found, checks for
content/blog/hello-world/index.php(folder match) - If still not found, returns a 404
This allows both file-based and folder-based URLs to coexist naturally.
Advantages
No Configuration
You don't need to define routes in a config file. The filesystem structure is the route definition. Add a file, and the URL exists immediately.
Transparency
The site structure is visible in your editor's file tree. There's no hidden routing logic to decipher.
Flexibility
You can use folders for logical grouping (/blog/), single files for simple pages (/about.php),
or mix both in the same project.
SEO-Friendly
Descriptive folder and file names become readable, keyword-rich URLs automatically.
Convention Over Configuration
This pattern implements the "Convention over Configuration" principle: Instead of writing route definitions, you follow a simple convention (folder structure = URLs) and the system handles the rest.
Nested Routes
Deep nesting works naturally:
content/
docs/
guides/
getting-started.php → /docs/guides/getting-started
deployment.php → /docs/guides/deployment
Index Pages as Landing Pages
Each folder can have an index.php that serves as the folder's landing page:
/blog → content/blog/index.php (blog listing)
/blog/2026 → content/blog/2026/index.php (2026 archive)
/blog/hello-world → content/blog/hello-world.php (specific post)