Structuring Content Routing in Sulu: Page Tree vs. Custom Templates
Learn how to manage content routing in Sulu CMS by choosing between standard page nodes and custom page types to balance editor flexibility and developer control.
09 Feb 2026, 11:13 UTC

The Routing Challenge in Sulu
When building a site in Sulu, the primary engineering decision is how to map your information architecture to the Page Tree. Because Sulu uses a hierarchical structure where each node represents a URL segment, a misalignment between your content model and the tree structure can lead to rigid templates or broken routing when the site scales.
The goal is to balance editor flexibility (the ability to move pages) with developer control (ensuring the correct Twig template renders the correct data).
Routing Strategy Comparison
Depending on the page's purpose, you will choose between using the default page structure or defining a custom page type. The following table compares these approaches:
| Feature | Standard Page Node | Custom Page Type |
|---|---|---|
| URL Generation | Automatic based on tree position | Automatic based on tree position |
| Template Mapping | Generic layout | Specific Twig template |
| Content Structure | Standard zones/blocks | Custom fields + zones/blocks |
| Use Case | Simple landing pages, blogs | Product catalogs, specialized dashboards |
Engineering Trade-offs
The Flexibility Trade-off: Using a standard page node allows editors to move content anywhere in the tree without breaking the layout. However, if you need a page to behave differently (e.g., a "Contact" page with a specific form field), a Custom Page Type is required. The risk here is template coupling: if you change the page type in the admin panel but forget to update the corresponding Twig file, the system will trigger a rendering error.
The Depth Trade-off: While Sulu handles hierarchical routing efficiently, extremely deep nesting can complicate URL management. Since moving a page automatically updates its URL path, deep trees increase the likelihood of breaking external backlinks. Always implement a redirect strategy when restructuring deep branches.
Implementing a Custom Page Route
To implement a specific content route, you must define the page type and map it to a template. This process assumes you are using a standard Sulu installation with Twig enabled.
Step 1: Define the Page Type
In the Sulu Admin panel, navigate to the Page Tree and create a new page. Instead of selecting a generic page, create or select a specific Page Type (e.g., product_detail). This tells Sulu to look for a specific template associated with this identifier.
Step 2: Create the Twig Template
Create the corresponding template file in your project directory. The path must align with the page type identifier. For a product_detail page, the file typically resides in:
templates/pages/product_detail.html.twigInside the template, define the Zones where editors can drop content blocks:
{{ page.zone('main_content') }}Step 3: Validation and Testing
To verify the routing is functioning correctly, perform these checks:
- URL Check: Confirm the URL in the admin panel reflects the hierarchy (e.g.,
/products/electronics/smartphone). - Zone Rendering: In the admin editor, add a "Block" (like a text or image block) into the
main_contentzone. Save and refresh the frontend. - Template Fallback: Temporarily rename the Twig file to verify that Sulu throws a template-not-found error, confirming the page is indeed mapped to that specific file and not a generic fallback.
Limitations and Risks
Sulu's routing is strictly tied to the Page Tree. You cannot create "virtual" routes that exist outside the tree without implementing a custom Symfony route, which bypasses the Sulu admin's page management. If you require a URL structure that does not mirror your content hierarchy, you must use a custom routing controller, though this removes the ability for editors to manage that page's position in the tree.
Rollback Procedure
If a new page type causes rendering errors across the site:
- Revert the page type in the Sulu Admin panel to a known working type (e.g.,
default). - Delete the custom Twig template if it contains syntax errors that prevent the site from booting.
- Clear the Symfony cache using
bin/console cache:clearto ensure the routing table is refreshed.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.