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
[docs] Add trailingSlash: true #22008
Conversation
@@ -128,6 +128,7 @@ module.exports = { | |||
}; | |||
}, | |||
exportTrailingSlash: true, |
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.
if you want to force trailing slashes the recommendation is to just use trailingSlash: true
--vercel/next.js#15598 (comment)
Sounds like we can remove this.
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 have tried without, it doesn't work correctly. We need to create a folder per route.
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.
Could you ask for clarification then? The statement makes it pretty clear that we only need one. It's not obvious how these interact and why we need both.
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.
exportTrailingSlash
impacts the export output, it goes from /autocomplete.html
to /autocomplete/index.html
. On the other hand trailingSlash
impacts how the links are generated. This is based on my observation, so far.
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.
So while we can set exportTrailingSlash: false
and trailingSlash: true
, and have the navigation work, it leads to 301/308 redirection once you refresh the page.
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.
Actually, if we look at the documentation, it's what it's described. https://nextjs.org/docs/api-reference/next.config.js/exportPathMap#adding-a-trailing-slash, change the HTML output.
I think that https://nextjs.org/docs/api-reference/next.config.js/trailing-slash would work if we weren't hosted on a CDN.
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.
On the other hand trailingSlash impacts how the links are generated. This is based on my observation, so far.
Why would this be different? If next already generates links based on a trailing slash why would it then not export them as such?
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.
Why would this be different?
I think that in theory, trailingSlash
is all we need. In practice, it's not enough. I think that it should lead to an issue on Next.js side. Let me do that.
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.
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.
Glad to see the private import droppted. But the indirection of routing and Link is a bit concerning. That was always a big pain point in next and I don't see them concerned with it at all.
Build on vercel/next.js#15598 (comment) and #21975 (comment). The main advantage is to reduce the gap between the development and production environment. I haven't noticed any regression. I'm happy to be able to remove the import of internal modules.