What URL will render the blog/[slug]/+page.svelte page when visiting /blog/hello-world?
medium
A. /blog/slug/hello-world
B. /blog/[slug]
C. /blog/hello-world
D. /blog/hello-world/+page
Solution
Step 1: Understand dynamic route matching
The folder blog/[slug] matches any URL starting with /blog/ followed by any value as slug.
Step 2: Match URL to folder structure
The URL /blog/hello-world matches the dynamic route [slug] with slug = 'hello-world'.
Final Answer:
/blog/hello-world -> Option C
Quick Check:
Dynamic folder matches URL part directly [OK]
Hint: Dynamic folders match URL parts exactly [OK]
Common Mistakes:
Confusing literal folder names with dynamic parameters
Expecting the URL to include brackets
Adding extra path segments incorrectly
4. You created a file src/routes/blog/[id].svelte instead of src/routes/blog/[id]/+page.svelte. What will happen when you visit /blog/123?
medium
A. The page will not load; routing fails because the file is misplaced
B. The page loads correctly showing the blog with id 123
C. A syntax error occurs during build
D. The app shows a 404 page
Solution
Step 1: Check correct file placement for routing
SvelteKit requires dynamic routes to be folders with +page.svelte inside, not files named with brackets.
Step 2: Understand routing failure
Placing [id].svelte as a file breaks routing because SvelteKit expects [id] as a folder.
Final Answer:
The page will not load; routing fails because the file is misplaced -> Option A
Quick Check:
Dynamic routes need folders with +page.svelte [OK]
Hint: Dynamic routes must be folders with +page.svelte inside [OK]
Common Mistakes:
Naming dynamic routes as files instead of folders
Expecting SvelteKit to accept bracketed filenames
Ignoring folder structure rules for routing
5. You want to create nested routes for category pages (/shop/electronics) and product pages (/shop/electronics/123) with a dynamic category and product ID. Which folder structure correctly implements this in SvelteKit?
hard
A. src/routes/shop/[category]/[product]/+page.svelte
B. src/routes/shop/[category]/+page.svelte and src/routes/shop/[category]/[product]/+page.svelte
C. src/routes/shop/[category]-[product]/+page.svelte
D. src/routes/shop/+page.svelte with query params for category and product
Solution
Step 1: Understand nested dynamic routes
To handle URLs like /shop/electronics (category) and /shop/electronics/123 (product), you need nested folders: one for [category] and inside it one for [product].
Step 2: Confirm folder structure with pages
Each folder can have its own +page.svelte. So src/routes/shop/[category]/+page.svelte can show category info, and src/routes/shop/[category]/[product]/+page.svelte shows product details.
Final Answer:
src/routes/shop/[category]/+page.svelte and src/routes/shop/[category]/[product]/+page.svelte -> Option B
Quick Check:
Nested folders for nested dynamic routes [OK]
Hint: Use nested folders for nested dynamic routes [OK]
Common Mistakes:
Putting multiple params in one folder name
Using query params instead of folder structure
Not nesting folders for nested routes
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.