The generate.dir option sets the output folder for static files.
Step 2: Apply config values
Since dir: 'public' is set, the static files will be generated inside a folder named 'public'.
Final Answer:
A folder named 'public' will be created -> Option D
Quick Check:
generate.dir = output folder [OK]
Hint: generate.dir sets output folder name [OK]
Common Mistakes:
Assuming default 'dist' folder is always used
Confusing generate.dir with buildDir
Thinking no folder is created
4. You run nuxt generate but your dynamic routes are missing from the static site. What is the likely cause?
medium
A. You forgot to add the dynamic routes in generate.routes
B. You set target to 'server' instead of 'static'
C. You did not install the Nitro preset
D. You used ssr: false in config
Solution
Step 1: Understand dynamic routes in static generation
Nuxt needs explicit dynamic routes listed in generate.routes to pre-build them.
Step 2: Check other options
target: 'server' disables static generation but does not explain missing dynamic routes if static is used; Nitro preset is internal; ssr: false disables SSR but not related to dynamic routes generation.
Final Answer:
You forgot to add the dynamic routes in generate.routes -> Option A
Quick Check:
Dynamic routes need generate.routes [OK]
Hint: Add dynamic routes in generate.routes to include them [OK]
Common Mistakes:
Assuming dynamic routes are auto-detected
Confusing ssr: false with static target
Thinking Nitro preset fixes missing routes
5. You want to build a blog with Nuxt static generation. Your posts are fetched from an API at build time. Which approach correctly generates static pages for each post?
hard
A. Fetch posts only on client side with mounted() and rely on client rendering
B. Use asyncData to fetch posts and list them, then add dynamic routes in generate.routes to pre-build each post page
C. Set ssr: false and generate pages dynamically on server
D. Use fetch() in components without configuring generate.routes
Solution
Step 1: Fetch posts at build time
Using asyncData fetches posts during build, enabling static generation.
Step 2: Configure dynamic routes for posts
Adding post URLs in generate.routes tells Nuxt to pre-build each post page as static HTML.
Step 3: Evaluate other options
Client-side fetching delays content and is not static; ssr: false disables server rendering; fetch() without generate.routes won't pre-build dynamic pages.
Final Answer:
Use asyncData and generate.routes to pre-build each post page -> Option B