-
Notifications
You must be signed in to change notification settings - Fork 79
Description
Astro Info
- Astro Version: 5.12.8
- Node Version: 22.18.0
- System: macOS (arm64)
- Package Manager: npm
- Output: static
- Adapter: none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Astro HTML Structure Bug - Minimal Reproduction
β Bug Successfully Reproduced
This minimal project demonstrates a consistent HTML structure corruption bug in Astro 5.12.8+ affecting nested dynamic routes.
π Bug Manifestation
Working Route: src/pages/taux/[date].astro
<!DOCTYPE html><html lang="fr">
<head>
<title>Taux du 2025-01-01 : 260 DZD - Site Test FranΓ§ais</title>
</head>
<body>
<!-- content -->
</body>
</html>
Broken Route: src/pages/en/taux/[date].astro
<!DOCTYPE html><html lang="en">
<head>
<title>Rate for 2025-01-01</title>
</head>: 260 DZD - English Test Site
<meta name="description"...>
<!-- content without <body> tag -->
</html>
π§ͺ Test Results
$ ./test-bug.sh
β
BUG REPRODUCED: French route has <body> tag, English route is missing it
Environment:
- Astro: [email protected]
- Node: v22.18.0
- System: Darwin arm64
π§ Issues Identified
- Missing
<body>
tag: English route completely lacks opening<body>
tag - Title content spillover: Title content appears outside the
<title>
element - Meta tag displacement: Meta description appears after title spillover
- Malformed document structure: Invalid HTML that fails validation
π Project Structure
astro-bug-repro/
βββ src/
β βββ components/
β β βββ Header.astro # Simple test component
β β βββ Footer.astro # Simple test component
β βββ pages/
β β βββ taux/[date].astro # β
Works correctly
β β βββ en/taux/[date].astro # β Generates malformed HTML
β βββ data.json # Minimal test data (3 entries)
βββ test-bug.sh # Automated test script
βββ README.md # Detailed documentation
π How to Test
- Clone/Download this reproduction project
- Install:
npm install
- Test:
./test-bug.sh
- Manual Check: Compare
dist/taux/2025-01-01/index.html
vsdist/en/taux/2025-01-01/index.html
π₯ Impact
This bug affects:
- International sites with nested language routes
- SEO due to invalid HTML structure
- Accessibility from malformed document structure
- User experience through visual inconsistencies
π¬ Root Cause Analysis
The issue appears to be in Astro's template compilation/rendering pipeline specifically for nested dynamic routes. The exact same template structure works at one nesting level but fails at deeper nesting levels, suggesting a parsing or compilation bug in the framework.
π Consistency
The bug is 100% reproducible across:
- β
Multiple builds (
npm run build
) - β
Development mode (
npm run dev
) - β Clean installs
- β Different dates in the dynamic route
- β Astro versions 5.12.8 and 5.13.3
π― For Astro Team
This minimal reproduction provides:
- Isolated test case with minimal dependencies
- Automated testing via
test-bug.sh
- Clear comparison between working/broken routes
- Documented expectations vs actual output
- Environment details for debugging
The templates are intentionally identical except for language content to isolate the structural compilation issue.
What's the expected result?
a well structured html
Link to Minimal Reproducible Example
https://stackblitz.com/~/github.com/FrenchTechLead/astro-bug-repro
Participation
- I am willing to submit a pull request for this issue.