Recap: Layouts
Part of the Next.js Essentials section of Coddy's React journey — lesson 16 of 47.
Challenge
MediumChapter recap: give Coddy Eats its shell: a shared nav and real tab titles.
- In
app/layout.jsx, inside<body>and above{children}, add a<nav>withid="nav"holding a<Link>to/withid="home-link"and the textHome, and a<Link>to/menuwithid="menu-link"and the textMenu. - Still in the layout, change the
metadatatitle to exactlyCoddy Eats. - In
app/menu/page.jsx, export ametadataobject with the titleOur Menu, so the menu tab names itself.
The tests read the tab title on both pages and check the nav is still there after moving to /menu.
Try it yourself
import './globals.css';
import Link from 'next/link';
export const metadata = {
title: 'My App',
};
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
{children}
</body>
</html>
);
}All lessons in Next.js Essentials
2Routing & Links
Folders Are RoutesNested RoutesLinking PagesDynamic RoutesNot Found PagesRecap: Routing3Layouts & Metadata
The Root LayoutShared NavigationNested LayoutsPage MetadataDynamic MetadataRecap: Layouts