I use this starter project:
https://github.com/vercel/nextjs-subscription-payments
The currently default content in above I want to lave original as home.
Now I want add admin and dashboard with different layout.
So I created route:
app/dashboard/layout.tsx - I rename this as DashboardLayout
app/dashboard/page.tsx
for test I place the same content from:
app/layout.tsx
app/page.tsx
The problem is now I have duplicated header and footer when I access to page dashboard. So looks like still in layout dashboard also fetch layout from root app layout.tsx
Can anyone help me with this structure?
2
Answers
It depends on your needs.
It depends on your needs.
1.If layouts are similiar. I suggest to modify your current navbar and footer for different pages. This will result in less code overall.
2.If Layouts are completelly different your best bet to add navbar and footer to your child layout. And leave main layout without header and footer.
3.If for some reason your header and footer must be in root layout. You can try hiding it on different pages. Although this can be hacky solution. And you might need to implement page loader to avoid double header footer effect.