-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Remove html extension if build.format is file #11684
base: main
Are you sure you want to change the base?
fix: Remove html extension if build.format is file #11684
Conversation
🦋 Changeset detectedLatest commit: 885f47e 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this is the correct fix. You should not add .html
to the final URLs.
Thanks! The |
I think not only in the sitemap integration, but on the build process the .html extension is added here https://github.com/withastro/astro/blob/main/packages/astro/src/core/build/generate.ts#L375 This url is used for creating the request which renders the page, and it adds the .html extension to the pathname, which makes the canonical url to contain the .html extension. The .html extension were added here: If the .html extension should not be visible, nor in the canonical url nor the sitemap, just removing it from the default state would fix it
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
Changes
This change adds .html extension to the sitemap urls if the build.format is set to file, this way the urls will match with the canonical url
In the related issue #11575 @ematipico suggest to remove the .html extension from the urls, not sure about it because the extension is forced in core/build/generate (function getUrlForPath), but I can undo this changes and modify that function
Sample project's structure:
Before urls:https://some-site.com/legal/aviso-legalhttps://some-site.com/legal/cookieshttps://some-site.com/legal/politica-de-privacidadhttps://some-site.com/legal/terminos-y-condicioneshttps://some-site.com/legalhttps://some-site.com/productos/carteles-personalizados/carteles-para-bodashttps://some-site.com/productos/carteles-personalizados/carteles-para-cumplea%C3%B1oshttps://some-site.com/productos/natalicioshttps://some-site.com/After urls:https://some-site.com/legal/aviso-legal.htmlhttps://some-site.com/legal/cookies.htmlhttps://some-site.com/legal/politica-de-privacidad.htmlhttps://some-site.com/legal/terminos-y-condiciones.htmlhttps://some-site.com/legal.htmlhttps://some-site.com/productos/carteles-personalizados/carteles-para-bodas.htmlhttps://some-site.com/productos/carteles-personalizados/carteles-para-cumplea%C3%B1os.htmlhttps://some-site.com/productos/natalicios.htmlhttps://some-site.com/With last commit all the .html extension has been removed
Testing
I need some help for the test, would be ok to create new fixture for static build with new build format?
Docs
This PR tries to fix the sitemap behaviour to match the canonical url explained in the docs, see #11575