Skip to content

Correct Astro.url root pathname for file format builds#15882

Merged
matthewp merged 1 commit intomainfrom
astro-url-html
Mar 13, 2026
Merged

Correct Astro.url root pathname for file format builds#15882
matthewp merged 1 commit intomainfrom
astro-url-html

Conversation

@matthewp
Copy link
Copy Markdown
Contributor

@matthewp matthewp commented Mar 12, 2026

Changes

  • fix root Astro.url.pathname in build.format: \"file\" builds to return /index.html instead of /.html

Testing

  • add integration assertions for root and non-root Astro.url.pathname behavior in page-format tests

Docs

N/A, bug fix

Closes #15866

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 12, 2026

🦋 Changeset detected

Latest commit: c0627e5

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@matthewp matthewp changed the title fix(astro): correct Astro.url root pathname for file format builds Correct Astro.url root pathname for file format builds Mar 12, 2026
@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 12, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 12, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing astro-url-html (c0627e5) with main (f47ac53)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (b16ee32) during the generation of this report, so f47ac53 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@matthewp matthewp marked this pull request as ready for review March 12, 2026 16:21
Copy link
Copy Markdown
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

As this is a change in behaviour from v5, we should add a migration guide entry I guess? In v5, Astro.url.pathname was / in both dev and build.

(I’d also like to understand the motivation for the change in behaviour if possible — in general we aim to avoid dev/build differences as it makes it trickier for users to write code that handles both.)

@matthewp
Copy link
Copy Markdown
Contributor Author

@delucis The documented behavior is that it includes .html: https://docs.astro.build/en/reference/configuration-reference/#effect-on-astrourl

I don't think these docs were added for v6 were they?

@delucis
Copy link
Copy Markdown
Member

delucis commented Mar 12, 2026

I don't think these docs were added for v6 were they?

Oh you’re right, these docs were also in v5:
https://v5.docs.astro.build/en/reference/configuration-reference/#effect-on-astrourl

So I guess we’re considering the v5 behaviour a bug, so not documenting the change? (I still find it weird that there’s a dev/build difference, but if it’s what we documented then that’s a conversation for another time.)

@matthewp
Copy link
Copy Markdown
Contributor Author

@delucis Yeah if I could do it over I would not include build.format as part of the Astro.url at all. It's a build configuration that says how to output files, it's not a configuration for how Astro treats URL, like trailingSlash is. Let's talk about changing this behavior in Astro 7.

@matthewp matthewp merged commit 759f946 into main Mar 13, 2026
26 checks passed
@matthewp matthewp deleted the astro-url-html branch March 13, 2026 15:15
@astrobot-houston astrobot-houston mentioned this pull request Mar 13, 2026
dadezzz pushed a commit to dadezzz/ice-notes that referenced this pull request Mar 20, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@astrojs/check](https://github.com/withastro/astro/tree/main/packages/language-tools/astro-check) ([source](https://github.com/withastro/astro/tree/HEAD/packages/language-tools/astro-check)) | [`0.9.7` → `0.9.8`](https://renovatebot.com/diffs/npm/@astrojs%2fcheck/0.9.7/0.9.8) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@astrojs%2fcheck/0.9.8?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@astrojs%2fcheck/0.9.7/0.9.8?slim=true) |
| [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`6.0.4` → `6.0.5`](https://renovatebot.com/diffs/npm/astro/6.0.4/6.0.5) | ![age](https://developer.mend.io/api/mc/badges/age/npm/astro/6.0.5?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/astro/6.0.4/6.0.5?slim=true) |

---

### Release Notes

<details>
<summary>withastro/astro (@&#8203;astrojs/check)</summary>

### [`v0.9.8`](https://github.com/withastro/astro/blob/HEAD/packages/language-tools/astro-check/CHANGELOG.md#098)

[Compare Source](https://github.com/withastro/astro/compare/@astrojs/check@0.9.7...@astrojs/check@0.9.8)

##### Patch Changes

- [#&#8203;15892](withastro/astro#15892) [`a2f597d`](withastro/astro@a2f597d) Thanks [@&#8203;Princesseuh](https://github.com/Princesseuh)! - Fixes Astro not being able to find astro check sometimes

- Updated dependencies \[[`7b4b254`](withastro/astro@7b4b254)]:
  - [@&#8203;astrojs/language-server](https://github.com/astrojs/language-server)@&#8203;2.16.5

</details>

<details>
<summary>withastro/astro (astro)</summary>

### [`v6.0.5`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#605)

[Compare Source](https://github.com/withastro/astro/compare/astro@6.0.4...astro@6.0.5)

##### Patch Changes

- [#&#8203;15891](withastro/astro#15891) [`b889231`](withastro/astro@b889231) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fix dev routing for `server:defer` islands when adapters opt into handling prerendered routes in Astro core. Server island requests are now treated as prerender-handler eligible so prerendered pages using `prerenderEnvironment: 'node'` can load island content without `400` errors.

- [#&#8203;15890](withastro/astro#15890) [`765a887`](withastro/astro@765a887) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes `astro:actions` validation to check resolved routes, so projects using default static output with at least one `prerender = false` page or endpoint no longer fail during startup.

- [#&#8203;15884](withastro/astro#15884) [`dcd2c8e`](withastro/astro@dcd2c8e) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Avoid a `MaxListenersExceededWarning` during `astro dev` startup by increasing the shared Vite watcher listener limit when attaching content server listeners.

- [#&#8203;15904](withastro/astro#15904) [`23d5244`](withastro/astro@23d5244) Thanks [@&#8203;jlukic](https://github.com/jlukic)! - Emit the `before-hydration` script chunk for the `client` Vite environment. The chunk was only emitted for `prerender` and `ssr` environments, causing a 404 when browsers tried to load it. This broke hydration for any integration using `injectScript('before-hydration', ...)`, including Lit SSR.

- [#&#8203;15933](withastro/astro#15933) [`325901e`](withastro/astro@325901e) Thanks [@&#8203;ematipico](https://github.com/ematipico)! - Fixes an issue where `<style>` tags inside SVG components weren't correctly tracked when enabling CSP.

- [#&#8203;15875](withastro/astro#15875) [`c43ef8a`](withastro/astro@c43ef8a) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Ensure custom prerenderers are always torn down during build, even when `getStaticPaths()` throws.

- [#&#8203;15887](withastro/astro#15887) [`1861fed`](withastro/astro@1861fed) Thanks [@&#8203;ematipico](https://github.com/ematipico)! - Fixes an issue where the build incorrectly leaked server entrypoint into the client environment, causing adapters to emit warnings during the build.

- [#&#8203;15888](withastro/astro#15888) [`925252e`](withastro/astro@925252e) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fix a bug where `server:defer` could fail at runtime in prerendered pages for some adapters (including Cloudflare), causing errors like `serverIslandMap?.get is not a function`.

- [#&#8203;15901](withastro/astro#15901) [`07c1002`](withastro/astro@07c1002) Thanks [@&#8203;delucis](https://github.com/delucis)! - Fixes JSON schema generation for content collection schemas that have differences between their input and output shapes.

- [#&#8203;15882](withastro/astro#15882) [`759f946`](withastro/astro@759f946) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fix `Astro.url.pathname` for the root page when using `build.format: "file"` so it resolves to `/index.html` instead of `/.html` during builds.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My43Ni4yIiwidXBkYXRlZEluVmVyIjoiNDMuNzYuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: Renovate Bot <renovate@zarantonello.dev>
Co-committed-by: Renovate Bot <renovate@zarantonello.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Astro.url regression in v6 with build.format: "file"

4 participants