Skip to content

fix: prevent duplicate navbar on 404 page#9862

Merged
jcanalesluna merged 1 commit intonilbuild:masterfrom
adinjithj:fix/duplicate-navbar-404
Apr 20, 2026
Merged

fix: prevent duplicate navbar on 404 page#9862
jcanalesluna merged 1 commit intonilbuild:masterfrom
adinjithj:fix/duplicate-navbar-404

Conversation

@adinjithj
Copy link
Copy Markdown
Contributor

Fix: Duplicate Navbar on 404 Page

Fixes #9841

Problem

When visiting invalid routes like /questions/redux, the 404 page renders two identical navbars. This happens because Astro.rewrite('/404') causes the 404 page's BaseLayout to render its default <Navigation /> in addition to the one from the rewriting page's context.

Solution

Explicitly fill the page-header slot in 404.astro with a single <Navigation /> component. This overrides BaseLayout's default slot content, ensuring only one navbar renders regardless of whether the page is accessed directly or via Astro.rewrite().

Changes

  • src/pages/404.astro: Added import Navigation and <Navigation slot='page-header' />

Testing

  • Visited /questions/redux → single navbar ✓
  • Visited /nonexistent-roadmap → single navbar ✓
  • Visited valid pages (/, /frontend) → no regression ✓

Override the page-header slot in 404.astro to explicitly render
Navigation once, preventing duplication when Astro.rewrite('/404')
is called from dynamic route pages.

Fixes kamranahmedse#9841
Copilot AI review requested due to automatic review settings April 16, 2026 20:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Resolves a UI duplication bug where the 404 page can show two navbars when reached via Astro.rewrite('/404'), by explicitly overriding the BaseLayout header slot on the 404 page.

Changes:

  • Import Navigation into src/pages/404.astro.
  • Provide <Navigation slot='page-header' /> to explicitly override BaseLayout’s default page-header slot fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jcanalesluna jcanalesluna merged commit 53bf546 into nilbuild:master Apr 20, 2026
3 of 4 checks passed
@adinjithj adinjithj deleted the fix/duplicate-navbar-404 branch April 21, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate Navbar displayed on "Not found" page

3 participants