Skip to content
QuiznExam

Metadata & SEO Optimization in Next.js

Test your knowledge of metadata and SEO optimization in Next.js, including the Metadata API, title, description, keywords, Open Graph, Twitter cards, robots, sitemaps, canonical URLs, and dynamic metadata.

15
Questions
12 min
Time limit
Medium
Difficulty

No sign-up needed · Last updated:

Save your score

At least 8 characters.

Forgot password?

Related quizzes

All 15 questions and answers Spoilers: this shows the questions and answers. Try the quiz first! Open
  1. 1. Which API is used to define metadata in the Next.js App Router?

    • A. Metadata API
    • B. SEO API
    • C. Head API
    • D. Meta API
    Show answer

    A. Metadata API

    Next.js provides the Metadata API for defining metadata in layouts and pages within the App Router.

  2. 2. Which property can be used to define the page title in a Next.js metadata object?

    • A. title
    • B. pageTitle
    • C. heading
    • D. metaTitle
    Show answer

    A. title

    The title property of the metadata object is used to define the document title.

  3. 3. Which metadata property is commonly used to provide a description for search engines?

    • A. description
    • B. summaryText
    • C. seoDescription
    • D. pageSummary
    Show answer

    A. description

    The description metadata field provides a description of the page that can be used by search engines and other platforms.

  4. 4. Where can static metadata be exported in a Next.js App Router page or layout?

    • A. Using an exported metadata object
    • B. Using only a metadata.json file
    • C. Using a seo.config file
    • D. Using only HTML comments
    Show answer

    A. Using an exported metadata object

    A page or layout can export a metadata object to define static metadata.

  5. 5. Which function is used to generate metadata dynamically based on route or other data?

    • A. generateMetadata
    • B. createMetadata
    • C. getMetadata
    • D. buildMetadata
    Show answer

    A. generateMetadata

    Next.js provides the generateMetadata function for generating metadata dynamically based on parameters, parent metadata, or fetched data.

  6. 6. Which metadata feature is used to control how a page appears when shared on platforms that support Open Graph?

    • A. openGraph
    • B. socialGraph
    • C. shareCard
    • D. socialPreview
    Show answer

    A. openGraph

    The openGraph metadata field can define information such as title, description, URL, and images for Open Graph previews.

  7. 7. Which metadata field can define information for Twitter or X card previews?

    • A. twitter
    • B. xCard
    • C. social
    • D. twitterMeta
    Show answer

    A. twitter

    The twitter metadata field can be used to configure metadata for Twitter or X card previews.

  8. 8. What is the main purpose of a canonical URL?

    • A. To indicate the preferred URL for a page when similar or duplicate URLs exist
    • B. To redirect every visitor to the homepage
    • C. To hide a page from search engines
    • D. To create a sitemap automatically
    Show answer

    A. To indicate the preferred URL for a page when similar or duplicate URLs exist

    A canonical URL helps search engines understand which URL should be treated as the preferred version of a page.

  9. 9. Which Next.js metadata configuration can be used to control search engine crawling and indexing instructions?

    • A. robots
    • B. crawler
    • C. searchEngine
    • D. indexing
    Show answer

    A. robots

    The robots metadata field can define directives such as whether search engines should index a page or follow its links.

  10. 10. What is the purpose of a sitemap in SEO?

    • A. To provide search engines with information about URLs available for crawling
    • B. To replace the website navigation
    • C. To store database records
    • D. To automatically improve page speed
    Show answer

    A. To provide search engines with information about URLs available for crawling

    A sitemap provides search engines with a structured list of URLs that can help them discover pages on a website.

  11. 11. Which file convention can be used in the Next.js App Router to generate a sitemap?

    • A. sitemap.js
    • B. seo.js
    • C. urls.js
    • D. searchmap.js
    Show answer

    A. sitemap.js

    Next.js supports the sitemap.js file convention for generating a sitemap programmatically.

  12. 12. Which file convention can be used to define robots.txt behavior in the Next.js App Router?

    • A. robots.js
    • B. crawler.js
    • C. robots-config.js
    • D. search.js
    Show answer

    A. robots.js

    Next.js supports the robots.js file convention for generating robots.txt content programmatically.

  13. 13. Why is a unique and descriptive page title important for SEO?

    • A. It helps search engines and users understand the page topic
    • B. It automatically guarantees the highest search ranking
    • C. It replaces the need for page content
    • D. It prevents all duplicate content
    Show answer

    A. It helps search engines and users understand the page topic

    A clear, descriptive title provides useful context about the page and can influence how the page appears in search results.

  14. 14. What is one advantage of defining metadata at a layout level in Next.js?

    • A. Metadata can be shared across pages in that route segment
    • B. It prevents child pages from having any metadata
    • C. It automatically creates database indexes
    • D. It disables search engine crawling
    Show answer

    A. Metadata can be shared across pages in that route segment

    Metadata defined in a layout can provide shared metadata for pages within that layout hierarchy, while child pages can define additional or overriding metadata.

  15. 15. Which approach is most appropriate when metadata needs to change based on a dynamic route such as a product ID?

    • A. Use generateMetadata with the route parameters
    • B. Hard-code the same title for every product
    • C. Put the title only in a CSS file
    • D. Use a JavaScript alert for the page title
    Show answer

    A. Use generateMetadata with the route parameters

    generateMetadata can use dynamic route parameters and other data to create page-specific titles, descriptions, and other metadata.