
File-Based Routing
Create folders and files - Barry maps them to clean URLs automatically.
Routing
Barry’s routing system is powered by your file structure. Each folder inside the routes/ directory maps to a URL path. Static routes match folder names directly, while dynamic segments use folder names that begin with an underscore (e.g., _slug) to handle parameters like blog post slugs or user IDs.How Routing Works
Every folder in the routes/
directory corresponds to a URL on your site. Routes are powered by a combination of index.html
(for markup) and optional index.server.go
(for dynamic logic). This makes routing entirely predictable and file-based.
You can build complex sites by combining:
- Static Routes for clean, fixed URLs like
/about
or/docs/setup
- Dynamic Routes for variable content like
/blog/my-post
- Deeply Nested Routes for hierarchies like
/docs/api/auth
Every route must include an index.html
. For dynamic content, add an index.server.go
file. See Server Logic for more on that.
Best Practices
- Use lowercase folder names and hyphens for consistency
- Keep dynamic segments clearly named (e.g.,
_slug
,_id
) - Prefer static routes when possible - they're easier to cache and maintain
Routing Visual Summary
/routes
├── about/
│ └── index.html → /about
├── blog/
│ └── _slug/
│ └── index.html → /blog/my-post
└── docs/
└── setup/
└── index.html → /docs/setup
This structure directly maps your file tree to your URL hierarchy. No extra configuration required.