Switch from directory to file format in Astro#2356
Conversation
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
951bd1f to
598b82a
Compare
|
EDIT: Fixed by #2390 Original comment about
|
b81b00c to
d4111a0
Compare
The "file" format generates "name.html" files instead of default "name/index.html". This would make old links work, even without redirects on Cloudflare level, while still allowing the current link format with no extension. https://docs.astro.build/en/reference/configuration-reference/#buildformat
d4111a0 to
9cb245c
Compare
|
As a bonus, with the changes from this PR we can just enable In fact using lychee with |
| build: { | ||
| format: 'file', | ||
| }, | ||
| markdown: { |
There was a problem hiding this comment.
Okay, quite a bit of time has passed. Other than the .html extensions, have we run into any additional issues?
To be honest, I feel like we should move forward with the current approach, especially considering the redirects that have already been put in place (which I don't have the ability to remove anyway).
There was a problem hiding this comment.
Okay, quite a bit of time has passed. Other than the
.htmlextensions, have we run into any additional issues?
I don't think so. The thing that I found after creating this PR is that it just works with --include-fragments in lychee, which I think that we should enable. Fragment checking should also work with the current directory based version with more remapping.
To be honest, I feel like we should move forward with the current approach, especially considering the redirects that have already been put in place (which I don't have the ability to remove anyway).
The file format works with and without redirects (/page and /page.html just work, /page/ receives a 301 redirect to /page).
I initially wrote that this also lets us avoid 301s that add /, but while most links in menu don't have a trailing / (/api/express/ is the only one ending with /), links in content now have / appended since #2193 was merged (2 days ago).

The "file" format generates
name.htmlfiles instead of defaultname/index.html. This would make old links work, even without redirects on Cloudflare level, while still allowing the current link format with no extension. The only observable difference between current version and this PR is that the URLs no longer end with a/(GitHub/Netlify serve a 301).References: