-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Add trailing slash to auto generated sitemap.xml for directories only #10044
Comments
No that's not how this feature is designed sorry. There's not even a concept of "directory" in Docusaurus, only "docs categories". FYI we recently fixed a bug related to trailing slash not being applied to sitemap: 301 redirect is a server/host concern, not a Docusaurus concern. If your host serves 301 instead of 200, then you have to configure your host so that it serves 200 instead of 301. Those links are standard HTML relative links. If you want your pages to end with [table 1](./mydoc#table-1)
[table 2](mydoc2#table-2) We have a whole doc section explaining why we don't recommend those kind of link, in particular due to the trailingSlash portability. https://docusaurus.io/docs/markdown-features/links I'm closing because no concrete repro was provided, this issue is quite messy, and to me this works as intended unless proven otherwise. If you want to discuss things further please create a runnable https://docusaurus.new/stackblitz repro |
So how would you configure the most used web server, Apache 2, not to use 301 redirects? Apache adds slashes by default: The root cause seems to be that sitemap.xml does not contain slashes while Apache requires slashes. A workaround would be to create sitemap.xml with trailing slashes as an option. Stackblitz obviously does not replicate a real world setup. Do you mean you can't replicate that sitemap.xml does not generate trailing slashes? |
This is not an option we recommend using. I'd suggest using Vercel or Netlify, and if you cannot GitHub pages. If you want to use Apache2, then it's your responsibility to figure out to configure it to serve a static deployment appropriately. I don't use Apache and I can't advise you how to configure it, although I'm pretty sure I already saw people using it successfully. Docusaurus is only responsible for building a static deployment, not hosting it. If you think our sitemap has a bug, then provide a repro and show what's the actual sitemap and what's the expected sitemap, given a fixed set of options. The expected behavior is that the sitemap contains URLs with/without |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
Bing.com shows a redirection message with HTTP 301 for every page because each link in sitemap.xml is missing a trailing slash. The redirection message shown by the Bing.com search site is WEBMoved Permanently. The document has moved here. It does not display the actual content.
I'd like to:
Also see #4134
Reproducible demo
No response
Steps to reproduce
adding
trailingSlash: true,
to docusaurus.conf.js.Expected behavior
Trailing slashes should only be used for actual directories.
Actual behavior
When 'trailingSlash' is added to docusaurus.conf.js within
const conf = {..}
is being refused with error messages:This creates a sitemap.xml with trailing slashes, building then fails due to broken links to anchors:
It looks like links to anchors are not created properly. The directories here are mydoc and mydoc2, the anchors referenced on the index pages are #table-1 and #table-2.
The link in the md file looks like this:
Your environment
Self-service
The text was updated successfully, but these errors were encountered: