Configuring flat URLs in TYPO3

/ updated on

Flat vs. hierarchical URLs

URLs can be composed in different ways. A flat URL contains only the path segment of the current page:

whereas a hierarchical URL has different path segments, mostly built from the TYPO3 page tree, such as:

Besides the SEO aspect, I think flat URLs have a big advantage: they don't change when you move the pages around the TYPO3 page tree.

URL segments in TYPO3

With TYPO3 v9 LTS, page routing was introduced into the TYPO3 core. A page has a new field "URL segment" which is automatically filled with the page title when the page is created. This URL segment can also be customized manually. By default, the full URL of a page is hierarchically built on the path segments of the parent pages.

Since TYPO3 v10 LTS, when moving a page in the page tree, the path segment can be automatically adjusted to the parent pages and a redirect to the new page path can be set up. However, this can lead to performance degradation if there are many redirects.

One solution may be to create flat URLs. This can be easily achieved by a configuration adjustment for the pages TCA:

$GLOBALS['TCA']['pages']['columns']['slug']['config']['generatorOptions']['prefixParentPageSlug'] = false;

Just paste this line of code into the appropriate file in your site package and you're done.