derschiw
derschiw

Reputation: 350

Escape Root Layout Svelte Sveltekit

According to the new routing system you can now group routes and have specific layout files in each group. These files inherit for their parent layout files. You can omit this, by using [email protected].

However in want to omit the root layout file at src/routes/layout.svelte. Is there a way to do that?

(Here is the guide: https://kit.svelte.dev/docs/advanced-routing#advanced-layouts)

Upvotes: 3

Views: 2859

Answers (3)

codingexplorer
codingexplorer

Reputation: 89

+page@ append @ to the page you want to break out of.

https://learn.svelte.dev/tutorial/breaking-out-of-layouts

Upvotes: -1

Marius Lupei
Marius Lupei

Reputation: 86

You can achieve that by using groups. Wrap all files from routes into a folder named “(app)” and other routes you don’t want to use the default layout in another group. For example, If you want to have a layout for ‘/’ and ‘/blog’ but don’t use it on ‘/login’ then you could use the following folder structure:

src/routes/
├ (app)/
│ ├ blog/
│ │ └ +page.svelte
│ ├ +page.svelte
│ └ +layout.svelte
└ (login)/
   ├ login/
   │ └ +page.svelte
   └ +layout.svelte

Upvotes: 7

brunnerh
brunnerh

Reputation: 185225

You can't.

Just make the root layout empty (i.e. it only contains <slot />).

Upvotes: 3

Related Questions