Bird
Raised Fist0
Vueframework~5 mins

Static site generation with Nuxt in Vue - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is Static Site Generation (SSG) in Nuxt?
Static Site Generation means Nuxt pre-builds all pages as static HTML files during build time. This makes the site fast and easy to host.
Click to reveal answer
beginner
How do you enable Static Site Generation in a Nuxt project?
Set target: 'static' in nuxt.config.js. Then run npm run generate or yarn generate to build static files.
Click to reveal answer
beginner
What command do you run to generate a static site in Nuxt?
Run npm run generate or yarn generate. This creates static HTML files in the dist/ folder.
Click to reveal answer
intermediate
How does Nuxt handle dynamic routes during static generation?
You use the generate.routes property in nuxt.config.js to specify dynamic paths so Nuxt can pre-render them.
Click to reveal answer
beginner
Why is Static Site Generation good for performance and SEO?
Because pages are pre-built as static HTML, they load very fast and search engines can easily read the content without running JavaScript.
Click to reveal answer
Which Nuxt config option sets the project to generate a static site?
Amode: 'universal'
Bssr: true
Ctarget: 'static'
Dbuild: 'static'
What command builds the static files in Nuxt?
Anuxt generate
Bnuxt build
Cnuxt start
Dnuxt serve
How do you tell Nuxt which dynamic routes to pre-render?
AUse <code>asyncData</code> only
BAdd routes in <code>generate.routes</code> in <code>nuxt.config.js</code>
CSet <code>ssr: false</code>
DUse <code>router.push()</code> in components
What is a benefit of static sites generated by Nuxt?
APages cannot be cached
BPages require a Node.js server to run
CPages are generated on every user request
DPages load instantly without server delays
Which of these is NOT true about Nuxt static generation?
AIt requires a backend server to render pages on demand
BIt improves SEO by serving pre-rendered HTML
CIt creates files you can host on any static server
DIt can pre-render dynamic routes if configured
Explain how to set up and generate a static site using Nuxt.
Think about config options and the build command.
You got /3 concepts.
    Describe why static site generation improves website performance and SEO.
    Consider how static files differ from server-rendered pages.
    You got /3 concepts.

      Practice

      (1/5)
      1. What does static site generation (SSG) in Nuxt do before users visit the site?
      easy
      A. Requires a server to render pages on demand
      B. Generates pages dynamically on each user request
      C. Builds all pages ahead of time as static files
      D. Only builds the homepage statically

      Solution

      1. Step 1: Understand static site generation concept

        Static site generation means creating all pages before users visit, so they are ready as static files.
      2. Step 2: Apply to Nuxt behavior

        Nuxt with static target builds all pages ahead, not on demand or partially.
      3. Final Answer:

        Builds all pages ahead of time as static files -> Option C
      4. Quick Check:

        SSG = Pre-build pages [OK]
      Hint: SSG means pre-building pages before user visits [OK]
      Common Mistakes:
      • Confusing static generation with server-side rendering
      • Thinking pages build on each request
      • Assuming only homepage is static
      2. Which Nuxt configuration option enables static site generation?
      easy
      A. target: 'static'
      B. mode: 'universal'
      C. ssr: false
      D. buildModules: ['@nuxt/static']

      Solution

      1. Step 1: Identify Nuxt config for static generation

        Nuxt uses target: 'static' to enable static site generation.
      2. Step 2: Check other options

        ssr: false disables server-side rendering but does not enable static generation; mode is deprecated; buildModules with '@nuxt/static' is invalid.
      3. Final Answer:

        target: 'static' -> Option A
      4. Quick Check:

        Static target = 'static' [OK]
      Hint: Look for target set to 'static' in config [OK]
      Common Mistakes:
      • Using ssr: false instead of target: 'static'
      • Confusing mode with target
      • Assuming buildModules enables static
      3. Given this Nuxt config snippet, what will be the output folder after running nuxt generate?
      export default {
        target: 'static',
        generate: {
          dir: 'public'
        }
      }
      medium
      A. A folder named 'build' will be created
      B. A folder named 'dist' will be created
      C. No folder will be created automatically
      D. A folder named 'public' will be created

      Solution

      1. Step 1: Understand generate.dir option

        The generate.dir option sets the output folder for static files.
      2. Step 2: Apply config values

        Since dir: 'public' is set, the static files will be generated inside a folder named 'public'.
      3. Final Answer:

        A folder named 'public' will be created -> Option D
      4. 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

      1. Step 1: Understand dynamic routes in static generation

        Nuxt needs explicit dynamic routes listed in generate.routes to pre-build them.
      2. 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.
      3. Final Answer:

        You forgot to add the dynamic routes in generate.routes -> Option A
      4. 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

      1. Step 1: Fetch posts at build time

        Using asyncData fetches posts during build, enabling static generation.
      2. Step 2: Configure dynamic routes for posts

        Adding post URLs in generate.routes tells Nuxt to pre-build each post page as static HTML.
      3. 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.
      4. Final Answer:

        Use asyncData and generate.routes to pre-build each post page -> Option B
      5. Quick Check:

        asyncData + generate.routes = static dynamic pages [OK]
      Hint: Use asyncData and generate.routes for static dynamic pages [OK]
      Common Mistakes:
      • Fetching posts only on client side
      • Not adding dynamic routes in generate.routes
      • Disabling SSR with ssr: false
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard