Static output always writes `foo.html`, so trailing-slash URLs 404 on hosts like GitHub Pages
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 42/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript, vite
- 领域
- build-system, devops
调研方向
Start with packages/void/src/prerender-render.ts, especially outputFileForPath, and compare its current path mapping with the GitHub Pages behavior described in the issue. Review the dev server's trailing slash redirect and the interaction with cloudflare.assets.html_handling in issue #580 before proposing the setting. Done means the output option, redirect behavior, and Cloudflare interaction have a documented and agreed direction.
由索引模型根据 Issue 内容生成。
描述
What happens
With output: 'static', every prerendered page except / is written as <path>.html (outputFileForPath in packages/void/src/prerender-render.ts). A section with an index page and child pages, such as
pages/posts/index.island.tsx
pages/posts/hello.md
builds to
dist/client/posts.html
dist/client/posts/hello.html
There is no option to write posts/index.html instead. Seen with Void 1.3.0; outputFileForPath is unchanged on current main.
Why it matters
The SSG guide says the static output works for self-hosting and covers hosting dist/client/ yourself. GitHub Pages doesn't map a trailing-slash URL to foo.html. I published the same layout on GitHub Pages (honbin/github-pages-trailing-slash, checked on 2026-10-29):
| URL | foo.html layout (Void today) |
foo/index.html layout |
|---|---|---|
/posts |
200 | 301 to /posts/ |
/posts/ |
404 | 200 |
/posts/hello |
200 | 301 to /posts/hello/ |
/posts/hello/ |
404 | 200 |
So with Void's output, every trailing-slash URL except / returns 404, including /posts/, where posts.html sits next to a posts/ directory without an index.html. That breaks any site whose links and canonical URLs end with a slash. Cloudflare resolves both foo.html and foo/index.html (as noted in prerender-render.ts), so this doesn't show up with Void's own deploys.
Current workaround
We move the files in CI after vp build:
find dist/client -name '*.html' ! -name index.html ! -name 404.html | while read -r file; do
mkdir -p "${file%.html}"
mv "$file" "${file%.html}/index.html"
done
Related behavior
The dev server redirects /posts/ to /posts with a 301, so dev assumes URLs without a trailing slash. A directory-style output would probably need the dev redirect to follow the same choice.
Question
Would you be open to an option for directory-style static output (for example, a trailingSlash-like setting next to output: 'static')? Open points I can see:
- the setting's name and where it lives
- whether the dev server redirect follows it
- how it combines with
cloudflare.assets.html_handling(#580)
Happy to send a PR once the direction is clear.
- 主要语言
- TypeScript
- 星标
- 580
- 派生
- 56
- 平均合并
- 12 小时 10 分钟
- 30 天内合并 PR
- 163
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
voidzero-dev/void 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
voidzero-dev/void#645 ·
维护者通常 1 天内回复
-
难度 4/5 1-2 天 新手友好度 48/100
voidzero-dev/void#644 ·
维护者通常 1 天内回复
-
React: `action()` and `router.visit()` never resolve when awaited in a transition可能已有人在做 @cpojer 于 1 天前认领。 未关闭
voidzero-dev/void#643 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 57/100
voidzero-dev/void#636 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 67/100
voidzero-dev/void#635 ·
维护者通常 1 天内回复
查看 voidzero-dev/void 的全部 Issue
相似的 Issue
-
check:passed streams:add
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
level2 nsoc26
难度 2/5 1-3 小时 新手友好度 82/100
GauravKarakoti/SecureFlow#1488 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
deltachat/deltachat-desktop#6914 ·
维护者通常 2 天内回复
-
area:cli bug P4
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
bug from-studio
难度 2/5 1-3 小时 新手友好度 65/100
esengine/DeepSeek-Reasonix#14868 ·
维护者通常 1 天内回复