Challenge - 5 Problems
Open Graph Mastery in Next.js
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What is the output of this Next.js component with Open Graph metadata?
Consider this Next.js component that sets Open Graph metadata using the element. What will be the rendered HTML meta tags in the page head?
NextJS
import Head from 'next/head'; export default function Page() { return ( <> <Head> <meta property="og:title" content="My Page Title" /> <meta property="og:description" content="A description of my page." /> <meta property="og:image" content="https://example.com/image.png" /> </Head> <main> <h1>Welcome</h1> </main> </> ); }
Attempts:
2 left
💡 Hint
Open Graph meta tags use the 'property' attribute, not 'name'.
✗ Incorrect
Open Graph metadata requires meta tags with the 'property' attribute set to 'og:title', 'og:description', and 'og:image'. The content attribute holds the value. Option D correctly uses this format.
📝 Syntax
intermediate2:00remaining
Which option causes a syntax error in Next.js Open Graph metadata usage?
Identify which code snippet will cause a syntax error when used inside a Next.js component's for Open Graph metadata.
NextJS
import Head from 'next/head'; export default function Page() { return ( <> <Head> {/* Insert meta tags here */} </Head> <main><h1>Hello</h1></main> </> ); }
Attempts:
2 left
💡 Hint
Self-closing tags in JSX must end with a slash.
✗ Incorrect
In JSX, all tags must be properly closed. Option B misses the closing slash on the meta tag, causing a syntax error.
🔧 Debug
advanced2:00remaining
Why does the Open Graph image not appear when sharing the page?
A developer added Open Graph meta tags in Next.js but the image does not show when sharing the page on social media. What is the most likely cause?
NextJS
import Head from 'next/head'; export default function Page() { return ( <> <Head> <meta property="og:title" content="My Site" /> <meta property="og:image" content="/images/og-image.png" /> </Head> <main><h1>Welcome</h1></main> </> ); }
Attempts:
2 left
💡 Hint
Open Graph requires full URLs for images.
✗ Incorrect
Open Graph metadata requires absolute URLs for images so social platforms can fetch them. Relative URLs like '/images/og-image.png' won't work.
❓ state_output
advanced2:00remaining
What is the effect of dynamically changing Open Graph metadata in Next.js?
If you update Open Graph meta tags dynamically on the client side after page load in Next.js, what will be the effect when sharing the page URL on social media?
NextJS
import Head from 'next/head'; import { useState, useEffect } from 'react'; export default function Page() { const [title, setTitle] = useState('Initial Title'); useEffect(() => { setTimeout(() => setTitle('Updated Title'), 3000); }, []); return ( <> <Head> <meta property="og:title" content={title} /> </Head> <main><h1>{title}</h1></main> </> ); }
Attempts:
2 left
💡 Hint
Social media scrapers read metadata from the server response, not client updates.
✗ Incorrect
Open Graph metadata is read by social media bots from the server-rendered HTML. Client-side changes after load do not affect what social media sees.
🧠 Conceptual
expert3:00remaining
Which Next.js feature best supports setting Open Graph metadata for multiple pages efficiently?
You want to set unique Open Graph metadata for many pages in a Next.js app without repeating code. Which approach is best?
Attempts:
2 left
💡 Hint
Think about code reuse and passing data per page.
✗ Incorrect
A reusable Head component lets you pass different Open Graph data per page, avoiding repetition and keeping metadata dynamic and maintainable.