-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Conversation
Deploy preview for reactjs ready! Built with commit 631f32c |
Will Netlify ever remove them? |
I don't think so. On their features page they say each URL is permanent:
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. |
Well, as long as Netlify is in business 😛 |
Search always uses the newest version, even for deployed previews and localhost. Probably should be tackled separately. edit: 💨 |
@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. |
Issue for versioned search: #803 |
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:
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 |
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. |
Is there some way to source both the redirects and the page content from the same source? Like
Another thing is that we could only show links to the latest semver-compatible docs for a major release, e.g., |
Yeah! Let me see if I can whip up another Gatsby startup plugin thingy for that.
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. |
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 |
src/pages/versions.js
Outdated
<ul> | ||
{versions.map(version => ( | ||
<li key={version.title}> | ||
<a href={version.path} rel="nofollow"> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dig it.
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). 😄 |
cc @danoc in case you know of a way to do this already ^ |
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 |
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. |
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. 😄 |
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. |
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. 😄 |
Nah, more no one has cared yet :-) |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I'm hungry 😢 |
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:
CHANGELOG
for release dates.master
branchUnfortunately, 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 withrel="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:
Resolves issue #85
Screenshot