fix: prevent duplicate navbar on 404 page#9862
Merged
jcanalesluna merged 1 commit intonilbuild:masterfrom Apr 20, 2026
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
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
Navigationintosrc/pages/404.astro. - Provide
<Navigation slot='page-header' />to explicitly overrideBaseLayout’s defaultpage-headerslot fallback.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 becauseAstro.rewrite('/404')causes the 404 page'sBaseLayoutto render its default<Navigation />in addition to the one from the rewriting page's context.Solution
Explicitly fill the
page-headerslot in404.astrowith a single<Navigation />component. This overridesBaseLayout's default slot content, ensuring only one navbar renders regardless of whether the page is accessed directly or viaAstro.rewrite().Changes
src/pages/404.astro: Addedimport Navigationand<Navigation slot='page-header' />Testing
/questions/redux→ single navbar ✓/nonexistent-roadmap→ single navbar ✓/,/frontend) → no regression ✓