-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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
feat(v2): add trailingSlash config option #4908
Conversation
✔️ [V1] 🔨 Explore the source changes: c17235f 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-1/deploys/60c0fe24933cf8000703b391 😎 Browse the preview: https://deploy-preview-4908--docusaurus-1.netlify.app |
…-generator-webpack-plugin
Size Change: 0 B Total Size: 620 kB ℹ️ View Unchanged
|
✔️ [V2] 🔨 Explore the source changes: c17235f 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/60c0fe2470bcda0008648986 😎 Browse the preview: https://deploy-preview-4908--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-4908--docusaurus-2.netlify.app/ |
@slorber The docs page is missing the navigation on the left. I can't tell if this is intentional or a bug introduced in this PR. See page https://docusaurus-trailing-slash-false.netlify.app/docs.
This has the right behavior for me based on my requirements in #3372 (comment). I see that the URLs in the pages, in the canonical meta tag, the sitemap, and the browser bar are all matching and contain trailing slashes. And Netlify's Pretty URL redirects users correctly. I will now wait for the canary build to test this on my site. |
Thanks, definitively not intentional but understand why it happens, due to using slug: "/". Other docs work fine see https://docusaurus-trailing-slash-false.netlify.app/docs/installation |
I wasn't able to get my site working with the current canary release. I get build errors and I'm not sure what the cause is. Yarn install output
Build output (has error)
Let me know if this is something that will go away with the next beta release. If this feels like a bug, let me know how I can debug it to help avoid this going to release. |
@thehappybug this does not look related to trailing slashes. From which version are you upgrading? May be related to refactor in #4759 It looks like we can't compute a proper date for some of your blog posts using this code: date = date ?? (await fs.stat(source)).birthtime;
const formattedDate = new Intl.DateTimeFormat(i18n.currentLocale, {
day: 'numeric',
month: 'long',
year: 'numeric',
}).format(date); Can you give me an idea of your blog post filenames + their frontmatter please? Do you see any post with a potentially wrong date filename pattern or frontmatter? As this is unrelated, I'd appreciate if you open a new issue instead of commenting this PR |
Hello, is this update included in the latest public builds? |
@Labirintami It is only available on canary right now. See: #3372 (comment) |
will be in beta.1, probably tomorrow I've written how to use a Canary release here: https://docusaurus.io/community/canary |
Motivation
Fixes #3372
After analyzing the behavior of multiple static hosting providers (see https://github.com/slorber/trailing-slash-guide), I think we should have a
trailingSlash
option (like Next.js has)This is a risky change that can have deep SEO impacts for some sites, so we are keeping a retrocompatible behavior by default.
It would allow 3 values:
/myPath/index.html
/myPath.html
/myPath/index.html
If the new behaviors are successful, we should add them to the init template, and deprecate the
undefined
legacy behavior with a Joi warning, telling the users to be extra careful about the potential SEO impacts.Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
Tests + deploy previews
I'm implementing a new
{trailingSlash: boolean | undefined}
config./path/index.html
/path.html
/path/index.html
Refer to https://github.com/slorber/trailing-slash-guide for how the files will be served by your host.
I've created 3 deployments to test this feature:
Note: using true/false instead of undefined allows to use Netlify with pretty URLs on without having any annoying redirection, but it's not the case for the undefined behavior that will keep redirecting with pretty URLs on (default behavior). Had to disable this.
PLEASE: help me review those deployments and let me know if you see any unwanted side-effects: now is a better time to complain than after merging the PR :)
Note: this feature is generic and in core, to avoid the need to have each plugin implement custom trailingSlash logic. In some cases it might require some plugin tweaks but it should work fine in a generic way for plugin authors in most cases.