Metadata is app/layout.js is not applying for the all the pages
Answered
Carolina Wren posted this in #help-forum
Carolina WrenOP
I am trying to add title to my next project I am adding the meta data in layout file of the app which should apply it to all the pages but it is not what could be the reason
The layout code:
The layout code:
"use client";
import "../globals.css";
import { useState, useEffect } from "react";
import Loader from "@/components/common/Loader";
import Sidebar from "@/components/Sidebar";
import Header from "@/components/Header";
import { Metadata } from "next";
export const metadata: Metadata = {
title: "SAT SPORTS247",
description: "",
// other metadata
};
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body suppressHydrationWarning={true}>
{/* <!-- ===== Main Content Start ===== --> */}
<main>
<div className="mx-auto max-w-screen-2xl p-4 md:p-6 2xl:p-10">
{children}
</div>
</main>
{/* <!-- ===== Main Content End ===== --> */}
</div>
)}
</div>
</body>
</html>
);
}5 Replies
Carolina WrenOP
Does it apply to layout file as well
yes
The metadata, generateMetadata, viewport and generateViewport exports are only supported in server components.
Carolina WrenOP
Thanks