Next.js Discord

Discord Forum

I want nav layout at "/" and every other page but not at "/demo"

Unanswered
Tibetan Terrier posted this in #help-forum
Open in Discord
Tibetan TerrierOP
In my website, I want my home page at / and every other page to have the navigation layout but I don't want it to be there in my /demo page. How can I achieve this?

4 Replies

I achive this by having the navbar as a component and then importing it to every page where i use it
Something like this:
import Navbar from "../../components/navbar.jsx";

export default function Page() {
  return (
    <>
      <Navbar />
      <h1>Page with navbar</h1>
    </>
  );
}
Asari
^If it's something more complex, you'll probably want to check out route groups
https://nextjs.org/docs/app/building-your-application/routing/route-groups