Dynamic Metadata
Next.js makes SEO easy. For dynamic pages, we use the `generateMetadata` function to pull titles and descriptions directly from WordPress.
Implementation
export async function generateMetadata({ params }) {
const post = await getPostBySlug(params.slug);
return {
title: `${post.title.rendered} | My Blog`,
description: post.excerpt.rendered,
};
}This ensures that when your post is shared on Twitter or found on Google, it has the correct title, description, and preview image.