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

Added redirects for old React versions #801

Merged
merged 11 commits into from
Apr 17, 2018
Merged

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Apr 13, 2018

Use Netlify's redirects API- and the fact that Netlify caches immutable builds of older versions of the site- to expose previous versions of the React documentation via a new "React Versions" page.

I did the following to identify the correct revisions to use:

  1. Lookd at the CHANGELOG for release dates.
  2. Cross-references Netlify build history for the master branch
  3. Picked the most recent build before we updated the site (e.g. merged a PR that adds new API docs)

Unfortunately, our Netlify history begins with version 16 RC3 (so we can't link back to an old 15.6 release).

Since Netlify has built this PR preview as 5ad0def873f2cf6608e0d48a--reactjs.netlify.com, we should be able to test these new redirects as:

A robots.txt file has also been added- along with rel="nofollow" attributes- to prevent search crawlers from indexing older versions of the site. (We want the latest release to be what shows up in search engines at all times.)

This versioning strategy should also work well by default with any localization strategy we use.

TODO:

  • Add a UI mechanism for viewing old revisions
  • Don't let search engines crawl older versions
  • Make versions configurable via a single YAML file
  • Determine if there's a way to use a subdomain of reactjs.org for versions rather than the netlify URL

Resolves issue #85

Screenshot

screen shot 2018-04-14 at 9 53 34 am

@reactjs-bot
Copy link

reactjs-bot commented Apr 13, 2018

Deploy preview for reactjs ready!

Built with commit 631f32c

https://deploy-preview-801--reactjs.netlify.com

@bvaughn bvaughn requested a review from gaearon April 13, 2018 16:50
@gaearon
Copy link
Member

gaearon commented Apr 13, 2018

Will Netlify ever remove them?

@consultwithmike
Copy link

This is awesome!

Looks good at first with this screenshot:

screen shot 2018-04-13 at 11 15 12 am

and remains good if I use the menus to navigate:

image

but if I use Search it will use the latest version:

image

@bvaughn
Copy link
Contributor Author

bvaughn commented Apr 13, 2018

Will Netlify ever remove them?

I don't think so. On their features page they say each URL is permanent:
screen shot 2018-04-13 at 10 18 09 am

but if I use Search it will use the latest version:

Yes. That's a good point. This is a limitation of our Algolia integration. It also applies to local builds or PR preview builds. At any given time, only the latest (master) build is searchable.

@gaearon
Copy link
Member

gaearon commented Apr 13, 2018

Well, as long as Netlify is in business 😛

@alexkrolick
Copy link
Collaborator

alexkrolick commented Apr 13, 2018

Search always uses the newest version, even for deployed previews and localhost. Probably should be tackled separately.

edit: 💨

@consultwithmike
Copy link

@alexkrolick we can tackle it separately with a different issue if we want, and I fully suspected that there was a code change coming down the pipeline, I just wanted to drop that information on the issue so we can get it handled.

@alexkrolick
Copy link
Collaborator

Issue for versioned search: #803

@bvaughn
Copy link
Contributor Author

bvaughn commented Apr 13, 2018

I added a drop-down toggle button for version switching. I'd love to get feedback, but I think I'm going to immediately replace it with a "older versions" index page because:

  • It would not work for mobile (since we don't even show the version number)
  • This would not work well once we have more than a few versions

I just wanted to add it so it would be available in the history of this PR.

(I didn't bother implementing global click-anywhere-outside-to-dismiss functionality because I don't plan on moving forward with this UI.)

Edit Looks like I forgot to actually commit the VersionToggler component, and I removed it right after pushing. Clown town! Whatever. It wouldn't have worked anyway for the reasons I mentioned.

@bvaughn
Copy link
Contributor Author

bvaughn commented Apr 13, 2018

Okay, I changed the version link in the header to link to a "Versions" page, which points to both the CHANGELOG and docs for recent releases of the site.

@alexkrolick
Copy link
Collaborator

alexkrolick commented Apr 13, 2018

Is there some way to source both the redirects and the page content from the same source? Like versions.yml:

versions:
	- title: 16.0
	  version: 16.0.0
	  url: 5ad0def873f2cf6608e0d48a--reactjs.netlify.com/version/16.0
	- title: 16.1
	  version: 16.1.1
	  url: 5ad0def873f2cf6608e0d48a--reactjs.netlify.com/version/16.1

Another thing is that we could only show links to the latest semver-compatible docs for a major release, e.g., 16.3.1, 15.6.3, 0.14.?. That's what Lodash does.

@bvaughn
Copy link
Contributor Author

bvaughn commented Apr 13, 2018

Yeah! Let me see if I can whip up another Gatsby startup plugin thingy for that.

Another thing is that we could only show links to the latest semver-compatible docs for a major release, e.g., 16.3.1, 15.6.3, 0.14.?. That's what Lodash does.

Maybe. I was thinking we could show minors (eg. 16.0, 16.1, 16.2) since there's been quite a bit of change between those lately.

@bvaughn
Copy link
Contributor Author

bvaughn commented Apr 13, 2018

Ok. I added a Gatsby plugin that reads version values from a YAML file and adds them as Netlify redirect rules. Also updated the Versions page to read from this same YAML file. It's a good bit of extra code compared to the previous version- but it simplifies the process of adding new versions.

Ideally, I could have done this in a simpler way using Gatsby's createRedirects action creator- but it doesn't see to support different domains yet (gatsbyjs/gatsby/issues/3782).

<ul>
{versions.map(version => (
<li key={version.title}>
<a href={version.path} rel="nofollow">
Copy link
Member

Choose a reason for hiding this comment

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

Since the top link used to always lead to a release, what do you think about making releases first-class entities on this page?

Something like

# React 16.2.0

* Changelog
* Documentation

# React 16.1.0

* Changelog
* Documentation

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 dig it.

@bvaughn
Copy link
Contributor Author

bvaughn commented Apr 14, 2018

I think we should move forward with this and follow up with the vanity subdomain URLs (assuming Netlify supports this- I've reached out to them about it on Twitter). This is a useful feature for the community, even as-is (with ugly URLs). 😄

@bvaughn
Copy link
Contributor Author

bvaughn commented Apr 14, 2018

cc @danoc in case you know of a way to do this already ^

@bvaughn
Copy link
Contributor Author

bvaughn commented Apr 14, 2018

I wonder if a modified version of this plug-in could be useful for other Gatsby sites that use Netlify? Or maybe as an addition to the existing gatsby-plugin-netlify plugin... cc @KyleAMathews

@KyleAMathews
Copy link
Contributor

Cool idea! The thought of duplicating documentation every time you do a new release has always filled me loathing (more-or-less) so this seems tons better. Relatively few people care about the older docs so pointing them to a snapshot seems like the least work for the most benefit.

It seems like this could be a lot simpler by fixing the redirect bug? Then you'd just need to read in the yaml file and create the redirects and the existing gatsby-plugin-netlify would setup the server redirects for you. I think all we'd need to do is to add a check here if the to path is absolute and if so, don't add the pathPrefix.

@danoc
Copy link
Contributor

danoc commented Apr 15, 2018

cc @danoc in case you know of a way to do this already ^

AFAIK, the only way to do this right now is with the "branch subdomains" feature in Netlify. Would be great if there was a way to "tag" certain Netlify deploys and provide clean-lookin' URLs. 😄

@bvaughn
Copy link
Contributor Author

bvaughn commented Apr 15, 2018

FYI there is a somewhat hacky option we could use to generate vanity subdomains (e.g. 16-0.reactjs.org) as per Netlify's tweet: https://twitter.com/NetlifySupport/status/985338587955810304

I'm not convinced this is worth it, TBH.

@bvaughn
Copy link
Contributor Author

bvaughn commented Apr 15, 2018

It seems like this could be a lot simpler by fixing the redirect bug? Then you'd just need to read in the yaml file and create the redirects and the existing gatsby-plugin-netlify would setup the server redirects for you.

Yes~ agreed! I assumed this bug was somewhat tricky to fix since it's been around for a while, but that would be an easier solution for sure. 😄

@KyleAMathews
Copy link
Contributor

Nah, more no one has cared yet :-)

@bvaughn
Copy link
Contributor Author

bvaughn commented Apr 15, 2018

Update on the vanity subdomains: According to Netlify support, the only way to have a subdomain like 16-0.reactjs.org point to a cached snapshot of the site would be to create a Git branch from the commit that generated that build, and then setup a branch subdomain. This approach would, I suppose, have the small added benefit of allowing us to update old branches if we ever needed to- but it also adds a bit of setup work each time we want to create a version.

I also tried another approach- using a 200 proxy redirect to gives us URLs like reactjs.org/16.0. Unfortunately it didn't work. (The latest version of the site loaded, rather than the older one I was trying to proxy.)

So, I think we should move forward as-is. 😄We can always follow up with the subdomain thing if anyone thinks it's important enough. (I don't.)

We can also simplify this implementation once the Gatsby redirect plug-in bug has been fixed.

@bvaughn bvaughn mentioned this pull request Apr 16, 2018
Copy link
Contributor

@flarnie flarnie left a comment

Choose a reason for hiding this comment

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

Let's ship it!

sushipit

@bvaughn bvaughn merged commit ec44237 into reactjs:master Apr 17, 2018
@bvaughn bvaughn deleted the versions branch April 17, 2018 15:56
@gaearon
Copy link
Member

gaearon commented Apr 17, 2018

Now I'm hungry 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants