4. You created a file pages/contact.vue but visiting /contact shows a 404 error. What is the most likely cause?
medium
A. The plugins/ folder is empty
B. The layouts/default.vue file is missing
C. The contact.vue file is inside components/ folder instead of pages/
D. You forgot to import contact.vue in pages/index.vue
Solution
Step 1: Check file location for routing
Nuxt auto-generates routes only from files inside the pages/ folder.
Step 2: Identify common mistakes
If contact.vue is inside components/, it won't create a route, causing 404 on /contact.
Final Answer:
The contact.vue file is inside components/ folder instead of pages/ -> Option C
Quick Check:
Pages folder files create routes [OK]
Hint: Pages must be inside pages folder for routing [OK]
Common Mistakes:
Placing pages in components folder
Thinking layouts cause 404
Assuming imports needed for pages
5. You want to create a Nuxt app with two different page layouts: one for public pages and one for admin pages. How should you organize your project structure to achieve this?
hard
A. Create layouts/public.vue and layouts/admin.vue, then specify layout in each page's definePageMeta
B. Put all pages in pages/ and import layouts manually inside each page component
C. Create two separate pages/ folders named public and admin without layouts
D. Use plugins/ to switch layouts dynamically based on route
Solution
Step 1: Understand layout usage in Nuxt
You can create multiple layouts inside layouts/ folder, each as a Vue component.
Step 2: Assign layouts per page
Use definePageMeta in each page to specify which layout to use, e.g., layout: 'admin' or layout: 'public'.
Step 3: Evaluate other options
Importing layouts manually or using plugins for layout switching is not the recommended Nuxt pattern.
Final Answer:
Create layouts/public.vue and layouts/admin.vue, then specify layout in each page's definePageMeta -> Option A
Quick Check:
Multiple layouts + definePageMeta = correct [OK]
Hint: Use multiple layouts and definePageMeta per page [OK]
Common Mistakes:
Trying to import layouts manually in pages
Not using definePageMeta for layout selection
Misusing plugins for layout switching
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.