Skip to content

JSX Comment between DOCTYPE and <html> tag removes <html> and <head> in output #1124

@z0rrn

Description

@z0rrn

Astro Info

Astro                    v5.15.3
Vite                     v6.4.1
Node                     v25.1.0
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When you add any JSX Comment between the <!doctype html> and the tag like this:

<!doctype html>
{/* Comment */}
<html lang="en">
	<head>
		<meta charset="UTF-8" />

the and tag are missing from the output file after running astro build. The file just starts with the doctype and then the tag after the tag like this:

<!DOCTYPE html>
<meta charset="UTF-8">

The issue is present with Bun v1.31.1 and Node.JS v25.1.0 (npm 11.6.2).

What's the expected result?

The outputted HTML should include the missing tags like this:

<!DOCTYPE html>
<html lang="en" data-astro-cid-sckkx6r4>

<head>
	<meta charset="UTF-8">

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-4rpbhfsi?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions