Page layouts work in a similar way for Blazor as they do for Razor Pages and views. A Blazor page normally has a layout, and a layout needs to declare where to render the contents of its pages through a @Body declaration, as illustrated in the following code snippet:
@inherits LayoutComponentBase
<div>This is a layout</div>
<div>Body goes here:</div>
@Body
However, Blazor layouts do not support multiple sections, only a single one (the body).
Layouts are declared on the route (see next section), on the _Imports.razor file—a way to apply a layout for multiple pages—like this:
@layout MyLayout
Or, they are declared in the code file for the component, using the [Layout] attribute, as follows:
[Layout(typeof(MainLayout))]
Normally, a layout should inherit from LayoutComponentBase, but it is necessary to declare this; otherwise, being a component, it would inherit from ComponentBase...