Exclude path segment of uri path

Hi Craftspeople,

the path structure is given by document tree which is fine for the menu structure.
The problem is I have to exclude a tree item from the url path.

eg. the given tree

├── dir1
│   └── page1
├── dir2
│   ├── dir2_1
│   │   └── page2
│   └── dir2_2
│       └── page3
└── page4

The path of page2 is /root/dir2/dir2_1/page2 and I would like to have /root/dir2/page2

The menu looks like this:

prototype(Website:Content.Menu) < prototype(Neos.Neos:Menu) {
    templatePath = 'resource://Website/Private/Templates/FusionObjects/Menu.html'


{namespace neos=Neos\Neos\ViewHelpers}
{namespace ts=Neos\Fusion\ViewHelpers}
<ul{attributes -> f:format.raw()}>
<f:render section="itemsList" arguments="{items: items}" />

<f:section name="itemsList">
    <f:for each="{items}" as="item">
        <li{ts:render(path: '{item.state}.attributes', context: {item: item}) -> f:format.raw()}>
        <a href="{neos:uri.node(node: item.node)}" class="navigation__link">
        <f:if condition="{item.subItems}">
                <div class="navigation__sub-menu navigation__sub-menu--level-{item.menuLevel} {f:if(condition: item.subItems.0.subItems, then: 'navigation__sub-menu--has-children')}">
                    <f:if condition="{item.menuLevel} == 1">
                            <div class="container">
                                    <f:render section="itemsList" arguments="{items: item.subItems}" />
                                <f:render section="itemsList" arguments="{items: item.subItems}" />

Hi Leonard,

welcome to discuss :slight_smile:

You can use the package https://github.com/breadlesscode/neos-nodetypes-folder to solve this.
It allows you to have path segments ignored.


Thx @sebobo for help.

Links in menu are fine now but every page after the folder node throws 404 in frontend. Neos backend (In-Place mode) shows still the excluded segment if I hover the link in menu and it shows the page if I click on the menu item in backend :thinking:

The links are not modified in the backend or it wouldn’t work currently.
So it only affects the frontend.

Have you tried clearing the caches and have you checked that no page is hidden?

ok, so I have to add rewrites in the proxy or redirects if I can live with all path segments.

Sorry, not sure what you mean. The feature doesn’t need any Webserver config.
Does it work now?

The problem is that uri.node(node: item.node) in menu is /root/dir2/page2 instead of /root/dir2/dir2_1/page2 now. This is correct because dir2_1 is a folder with Hide segment in uri path = true.

But it raises 404 because page2 is still under /root/dir2/dir2_1/page2

You have the package as dependency of your site package correct?