Nodejs.dev: Merging staging into master broke all existing links

Created on 21 May 2020  ·  12Comments  ·  Source: nodejs/nodejs.dev

Description

All links prior to merging staging into master are now completely broken since there was no redirect strategy in place. We've marketed nodejs.dev publicly as a way to learn more about Node.js and have now entirely broken all references, nuking the UX of the site for users who are trying to learn.

Expected result

Old backlinks should work.

Actual result

Old backlinks are broken.

bug

Most helpful comment

All the old links should be working now

All 12 comments

I think we can setup redirects in gatsby, do we have some set of links which are not working?

@benhalverson and I are working on this collaboratively together currently on fixing this

@designMoreWeb Let me know if any help needed

@tstreamDOTh if you want to work on this feel free.

Honestly feel this this is revert worthy and am sad that it's not been addressed in a meaningful way in 2 months.

@benhalverson Looking into this

Okay, I found this article. Seems like we can add another field in the md files called redirect for each page that includes the old urls like

title: How to log an object in Node.js
description: 'Logging objects in Node.js'
authors: flaviocopes, MylesBorins, fhemberger, LaRuaNa, ahmadawais
section: Getting Started
redirects:
  - /how-to-log-an-object-in-nodejs

and then follow through the rest.

I tried to do it but I couldn't get it to work :/

I'd love to help out if this hasn't been sorted out already. I'm struggling with the context for this issue, though. Was there a change in the URL structure so some old links that were published in other sites no longer work? What was the old structure?

Here's an example.
The old link was http://nodejs.dev/a-brief-history-of-nodejs
The new links have /learn/thing http://nodejs.dev/learn/a-brief-history-of-nodejs

I've tried fixing myself using the gatsby plugins but end up with links like http://nodejs.dev/learn/a-brief-history-of-nodejs/a-brief-history-of-nodejs

I'm actually going to pair with someone on this sometime this week.

I also tested a few plugins and they don't work very well.

Here is another way you could do it for all of the existing blog posts in gatsby-node.js using createRedirect 🤷‍♂️

  let redirects= [
    { from: `https://nodejs.dev/a-brief-history-of-nodejs`, to: `https://nodejs.dev/learn/a-brief-history-of-nodejs` }
  ]

  redirects.forEach(({ from, to }) => {
    createRedirect({
      fromPath: from,
      isPermanent: true,
      redirectInBrowser: true,
      toPath: to,
    })
  })

All the old links should be working now

Was this page helpful?
0 / 5 - 0 ratings