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

use friendly "semi-stable" urls for key versions #256

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

cburroughs
Copy link
Contributor

Currently all of the versioned docs have the explicit version in the url. This has the virtue of being
cool but has some awkwardness in practice. For example if one links to
https://www.pantsbuild.org/2.18/docs/using-pants/using-pants-in-ci from another webpage it will eventualy end up with the 'no longer maintained' banner. It isn't super fun to update every internal/wiki link every 6 weeks for a release.

This change introduces some "semi-stable" urls for key versions:

  • prerelease: The latest prerelease
  • dev: aka main aka "trunk"
  • stable: The most recent stable release

Redirects ensure that the versioned urls also work.

As an example, right now:

/stable/docs/using-pants/using-pants-in-ci is the doc for 2.21 and /2.21//docs/using-pants/using-pants-in-ci redirects to there. After the next release, /stable/docs/using-pants/using-pants-in-ci will be for 2.22 and /2.21/docs/using-pants/using-pants-in-ci will keep pointing to the 2.21 content.

I think this is reasonable compromise of easy of use with permanence.

FWIW the Offical Docusaurus position seems to be to prefer server side redirects facebook/docusaurus#9049 but as far as I can tell that isn't an option for GitHub Pages.

ref #221

Currently all of the versioned docs have the explicit version in the
url.  This has the virtue of being
[cool](https://www.w3.org/Provider/Style/URI) but has some awkwardness
in practice.  For example if one links to
https://www.pantsbuild.org/2.18/docs/using-pants/using-pants-in-ci
from another webpage it will eventualy end up with the 'no longer
maintained' banner.  It isn't super fun to update every internal/wiki
link every 6 weeks for a release.

This change introduces some "semi-stable" urls for key versions:
 * `prerelease`: The latest prerelease
 * `dev`: aka `main` aka "trunk"
 * `stable`: The most recent stable release

Redirects ensure that the versioned urls also work.

As an example, right now:

`/stable/docs/using-pants/using-pants-in-ci` is the doc for `2.21` and
`/2.21//docs/using-pants/using-pants-in-ci` redirects to there.  After
the next release, `/stable/docs/using-pants/using-pants-in-ci` will be
for `2.22` and `/2.21/docs/using-pants/using-pants-in-ci` will keep
pointing to the `2.21` content.

I think this is reasonable compromise of easy of use with permanence.

FWIW the Offical Docusaurus position seems to be to prefer server side
redirects facebook/docusaurus#9049 but as
far as I can tell that isn't an option for GitHub Pages.

ref #221
@cburroughs
Copy link
Contributor Author

To fully test locally:

time NODE_ENV=production NODE_OPTIONS="--max-old-space-size=12288" npm run build

Which takes ~half an hour on my poor old laptop.

@cburroughs
Copy link
Contributor Author

cc @thejcannon

redirects,
redirects: old_site_redirects,
createRedirects(existingPath) {
if (existingPath.includes("/dev/")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there ever a chance of /dev/ showing up elsewhere in a URL? Can .startsWith be used here?

createRedirects(existingPath) {
if (existingPath.includes("/dev/")) {
return [existingPath.replace("/dev/", `/${currentVersion}/`)];
} else if (existingPath.includes("/prerelease/")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment re string matching

`/${mostRecentPreReleaseVersion.shortVersion}/`
),
];
} else if (existingPath.includes("/stable/")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment re string matching

@huonw
Copy link
Contributor

huonw commented Aug 28, 2024

I like it.

I think this is reasonable compromise of easy of use with permanence.

This does sound like a reasonable compromise.

Brainstorming another idea: have the versioned links remained version, rather than redirect:

  • change: visiting /2.21/... will remain at that path and show the 2.21 content (i.e. not redirect to /stable/ now)
  • not changed: visiting /stable/... would currently show the content for 2.21 and then move to 2.22 (etc.)

(Bonus points: support pressing y to get a 'permalink' similar to Github, i.e. if on a /stable/... page the URL is rewritten to /2.21/....)

Example: https://doc.rust-lang.org/stable/std/ and https://doc.rust-lang.org/1.80.1/std/ are the same content, where the first is evergreen while the second is a permalink.

Thoughts? Maybe too much effort with how docusaurus works?

@cburroughs
Copy link
Contributor Author

Example: https://doc.rust-lang.org/stable/std/ and https://doc.rust-lang.org/1.80.1/std/ are the same content, where the first is evergreen while the second is a permalink.
Thoughts? Maybe too much effort with how docusaurus works?

I also like that more. My understanding of the linked docusaurus issue is that it is asking for more or less that. I think to do that today we would need to either:

  • Use server side redirects (I don't think an option with GitHub Pages)
  • Even more docusaurus hackery on top of a cp (again from the linked issue).

@thejcannon
Copy link
Member

(not thinking too hard about it) I do think this is a good change and an improvement 🙂

Copy link
Contributor

@huonw huonw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it. Thanks for explaining the options.

@@ -52,8 +52,8 @@ jobs:
- run: yarn install --frozen-lockfile
- run: npm run build
env:
NODE_ENV: "production"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not doubting this, but what was the reason to add this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the various nested ?: operators happen to work either way right now, but being explicit about building everything for the public site.

https://github.com/pantsbuild/pantsbuild.org/blob/main/docusaurus.config.js#L20

@cburroughs cburroughs merged commit 6136389 into main Sep 4, 2024
1 check passed
@cburroughs cburroughs deleted the csb/friendly-doc-urls branch September 4, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants