- Install the jekyll-redirect-from plugin
- update the front matter on posts to include
- Load a post and observe the browser redirect to the new location 👍
I was using GitHub Pages (Jekyll) for blogging, but recently switched to WordPress. I didn’t want to break old links, so I needed a way to permanently redirect.
An SO answer got me thinking about a
meta tag. Is there an efficient way to add this
meta tag to posts? Yes. Some old GitHub Enterprise Pages docs recommend using the jekyll-redirect-from plugin. We can confirm it’s supported for non-Enterprise Pages by looking at the list of supported plugins. And I see it works via a
Is the redirect permanent? Sort of. The HTTP response from GitHub is 200, but the HTML redirect includes a canonical
$ curl -v https://erikeldridge.com/notes/google-cloud-workstation.html < HTTP/2 200 < server: GitHub.com < content-type: text/html; charset=utf-8 ... <!DOCTYPE html> <html lang="en-US"> <meta charset="utf-8"> <title>Redirecting…</title> <link rel="canonical" href="https://blog.erikeldridge.com/2019/03/02/google-cloud-workstation/"> <script>location="https://blog.erikeldridge.com/2019/03/02/google-cloud-workstation/"</script> <meta http-equiv="refresh" content="0; url=https://blog.erikeldridge.com/2019/03/02/google-cloud-workstation/"> <meta name="robots" content="noindex"> <h1>Redirecting...</h1> <a href="https://blog.erikeldridge.com/2019/03/02/google-cloud-workstation/">Click here if you are not redirected.</a> </html>
script tag looks broken, but it’s shorthand for `window.location.href`.