The layout wraps content with header and footer, placing page content where <slot /> is.
Step 2: Insert page content at slot
The page's <h1>Welcome</h1> replaces the <slot /> in the layout.
Final Answer:
<header>Site Header</header><h1>Welcome</h1><footer>Site Footer</footer> -> Option A
Quick Check:
Layout header + page content + footer = B [OK]
Hint: Page content replaces in layout output [OK]
Common Mistakes:
Ignoring and missing page content
Placing page content before header
Only showing page content without layout parts
4. You created a +layout.svelte file but your pages show no content. What is the most likely cause?
medium
A. You used <slot></slot> instead of <slot />.
B. You forgot to include <slot /> in the layout file.
C. You named the file layout.svelte instead of +layout.svelte.
D. You placed the layout file inside the src/routes folder.
Solution
Step 1: Check layout file structure
If <slot /> is missing, page content has no place to render inside the layout.
Step 2: Verify other options
File naming and placement are important but missing <slot /> directly causes no page content to show.
Final Answer:
You forgot to include <slot /> in the layout file. -> Option B
Quick Check:
No means no page content shown = C [OK]
Hint: Always include in layouts to show page content [OK]
Common Mistakes:
Using wrong file name but still expecting content
Thinking is invalid (it's valid)
Placing layout outside routes folder (usually okay if nested)
5. You want to create a layout that adds a navigation bar only for pages inside src/routes/dashboard. Where should you place the +layout.svelte file to achieve this?
hard
A. Inside src/routes/dashboard/dashboard.svelte as a layout.
B. Inside src/routes/+layout.svelte to affect all pages.
C. Inside src/+layout.svelte to affect all routes including dashboard.
D. Inside src/routes/dashboard/+layout.svelte to affect only dashboard pages.
Solution
Step 1: Understand layout file scope
A +layout.svelte file affects all pages in its folder and subfolders.
Step 2: Choose folder for dashboard-only layout
Placing +layout.svelte inside src/routes/dashboard limits the layout to dashboard pages only.
Final Answer:
Inside src/routes/dashboard/+layout.svelte to affect only dashboard pages. -> Option D
Quick Check:
Layout location controls which pages it wraps = A [OK]
Hint: Put +layout.svelte in folder to scope layout to that folder [OK]
Common Mistakes:
Putting layout in root folder affects all pages
Naming a page file as layout
Placing layout outside routes folder
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.