Skip to content

Layout inheritance #112

Answered by daveaglick
ror3d asked this question in Q&A
Dec 5, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

It's definitely possible - nested layouts are built into the Razor engine and work the same way in Statiq as they do in ASPNET. So then the question becomes why they aren't working in your case.

You can see an example of nested layouts in the Statiq web site here: https://github.com/statiqdev/statiqdev.github.io/tree/develop/input/news

Notice how there's a _ViewStart.cshtml file that tells every page under the "news" folder to use the /news/_layout.cshtml layout. In turn, the /news/_layout.cshtml contains this block at the top:

@{
    Layout = @"/_layout.cshtml";
}

That instructs the /news/_layout.cshtml to nest inside the /_layout.cshtml layout.

I wonder if part of the confusion here mi…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ror3d
Comment options

Answer selected by ror3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants