#generateMetadata not creating on build

2 messages · Page 1 of 1 (latest)

kind isle
#

I'm having an issue getting my dynamic page metatags to be added to the HTML at build time. Instead it seems like the tags are being included in a body script. This is preventing me from displaying those metatags when linking the url on socials ect..

Is this the expected behavior of generateMetadata?

This is the code on my page. Instead of making an API request for the metadata I'm just accessing a JSON blob for that specific route slug. This method works fine on my static pages but is not working on the dynamic ones.

  params: {
    slug: string;
  }
}

export function generateStaticParams() {
  // return COURSES_ARR.map((course) => {
  //   slug: course.slug;
  // })
  return [{slug: "js"}, {slug: "ethereum"}, {slug:"solidity"}]
}

export function generateMetadata({ params: { slug }}: Params): Metadata{
  const metatags = PageMetatags(slug)
  return metatags;
}

// export const metadata = PageMetatags(params.slug)

export default function CoursePage({ params: { slug }}: Params) {
  const courseDetails = COURSES[slug];
  // if (!courseDetails) {
  //   redirect("/courses");
  // }
  const { showImageCarousel } = courseDetails;
  return (
    <div>
      <Hero courseDetails={courseDetails} />
      <About courseDetails={courseDetails} />
      <ShowImageCarousel show={showImageCarousel} />
      {/* <CourseStudentProjects courseDetails={courseDetails} /> */}
      <EarnCertificate courseDetails={courseDetails} />
      <CourseSpotlight courseDetails={courseDetails} />
      <RecommendCourse />
      <Syllabus courseDetails={courseDetails} />
    </div>
  );
}`
unreal marshBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)