I use following folder structure to organize my blazor wasm project:
Features
- Components
- Feature A
- Components
- Page1.razor
- Page2.razor
Index.razor
Shared
- MainLayout.razor
I've created a layout, that I want to use in most of the features.
I came up with following idea but I am struggling to implement this in blazor. SubPageLayout.razor:
@inherits LayoutComponentBase
@layout MainLayout
<div>
<span>@FeatureTitle</span>
@Menu
<div class="container">
<span>@PageTitle</span>
<div class="content">
@Body
</div>
</div>
</div>
Then I would create an Feature A/Index.razor page that uses the layout:
@page "/feature"
@layout SubPageLayout
<FeatureTitle>Feature A</FeatureTitle>
<Menu>
...
</Menu>
@Body
Then in Page1.razor:
@page "/feature/page-1"
<PageTitle>Page 1</PageTitle>
Content...
I have two related questions:
- What is the blazor-way to implement this nested layout?
- How can localhost/feature be redirected to localhost/feature/page? /feature in itself is just a wrapper providing a common layout and navigation for all the pages of that feature.

LayoutBase. But , there's nothing stopping you building your own more complex version. You can get the code from the DotNetCore Repo on Github. It all depends on how dynamic you want to be. How do you know Feature A has Pages A-1 and A-2 and Feature B has pages B-1, B-2, B-3, B-4, .....