Skip to content
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

Redirect /docs/latest-version to /docs/ #7087

Closed
2 of 7 tasks
legacydev opened this issue Apr 1, 2022 · 9 comments
Closed
2 of 7 tasks

Redirect /docs/latest-version to /docs/ #7087

legacydev opened this issue Apr 1, 2022 · 9 comments
Labels
closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests) feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.

Comments

@legacydev
Copy link

legacydev commented Apr 1, 2022

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

I need to link to the latest version specifically for future proofing (release links, etc). Ex: https://docusaurus.io/docs/2.0.0-beta.18
However, this results in "Not found".

2.0.0-beta.18 does exist at https://docusaurus.io/docs.

I expect https://docusaurus.io/docs/2.0.0-beta.18 to resolve to https://docusaurus.io/docs

Reproducible demo

No response

Steps to reproduce

  1. Go to https://docusaurus.io/docs/2.0.0-beta.18
  2. See "Not Found" page

Expected behavior

I expect https://docusaurus.io/docs/2.0.0-beta.18 to resolve to https://docusaurus.io/docs

Actual behavior

It goes to "Not found" page

Your environment

Self-service

  • I'd be willing to fix this bug myself.
@legacydev legacydev added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Apr 1, 2022
@Josh-Cena
Copy link
Collaborator

Hi! Our docs plugin never sets up redirects, see also #3407. You need to set up any kind of redirect yourself, either server-side (through 304) or client-side (through the client-redirects plugin).

You can also try the versions option and configure path: "2.0.0-beta.18" for your latest version, so you never have an unversioned URL at all.

@Josh-Cena Josh-Cena added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests) and removed bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Apr 1, 2022
@Josh-Cena Josh-Cena changed the title Specifying the Latest version in URL "Not Found" Redirect /docs/latest-version to /docs/ Apr 1, 2022
@slorber
Copy link
Collaborator

slorber commented Apr 6, 2022

@Josh-Cena we discussed a "version aliases" feature in the past but it never got implemented.

That looks quite similar to the current use case and could be useful.

Did a rough design here: #3285

@legacydev
Copy link
Author

legacydev commented Apr 11, 2022

Unless I'm misunderstanding, the versions plugin looks like a configuration for each version? Feels a little clunky for a resolution. Going to take a deeper look, but not entirely sure that this would support both versioned url + latest version url. We need both of these - one for documentation that needs to point to the latest (readme's in repos) and then specific points for pointing to the latest via version (release announcements, etc.) to preserve history

Server-side isn't really a viable option for us as we would have to submit a request through a different team each time we do a release

@slorber
Copy link
Collaborator

slorber commented Apr 13, 2022

@legacydev please explain your problem in a more concrete way, giving example URLs and expected content (or redirect, client or server) at each URL. It's hard to understand in text form.

Server-side isn't really a viable option for us as we would have to submit a request through a different team each time we do a release

There are solutions with modern CDN hosts (Netlify, Vercel and even homemade...) so that redirects can be committed to Git and controlled directly by devs

@tisonkun
Copy link

tisonkun commented Nov 15, 2022

@slorber Today I meet a requirement that exactly needs the version alias feature - for your information :)

See also apache/pulsar#17438.

@tisonkun
Copy link

@slorber and I maunally do the redirect as apache/pulsar-site#288.

@slorber
Copy link
Collaborator

slorber commented Nov 16, 2022

@tisonkun FYI the redirect is always done better server-side.
If we ever build something it will be at most a client redirect and be less than ideal.

In my opinion your implemented solution is not ideal either, you'd better use a server redirect.

For example, using a _redirects file on Netlify it's as simple as adding one of those 3 declarations:

# Redirect from /docs/latest/* to /docs/2.3.0/* (always, because of !)
/docs/latest/*                 /docs/2.3.0/:splat           301!

# Redirect from /docs/* to /docs/2.3.0/*  (only if no matching static file can't be served at /docs/*)
/docs/*                 /docs/2.3.0/:splat           301

# Proxy from /docs/latest/* to /docs/2.3.0/* (ie the URL still contains /latest/ but the correct static file is served)
/docs/latest/*                 /docs/2.3.0/:splat           200

And the non-redirect alias can be achieved pretty simply with cp -R build/docs/2.3.0 build/docs/latest as a post-build step

Hope this helps

@tisonkun
Copy link

tisonkun commented Nov 17, 2022

@slorber Thanks for your information! The Apache Pulsar website is hosted on an Apache Web Server (of course, lol) and I'm still learning how to configure server-side redirections programmatically...

For example, if you Redirect from /docs/* to /docs/2.3.0/* (only if no matching static file can't be served at /docs/*), what if a 404 page /docs/2.3.0/nonexisting? It can cause some false positive redirections (Well, a "standard" * matches only one level down, but the syntax always varies from server to server).

@slorber
Copy link
Collaborator

slorber commented Nov 17, 2022

😅 I can't tell you how to configure Apache Web Server unfortunately, it's been a while I haven't touched that and I don't really regret it 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests) feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Projects
None yet
Development

No branches or pull requests

4 participants