June 30, 2017
At this point I have created a new blog and configured it to deploy to Firebase at a temporary URL. Now I need to configure the new site to properly redirect to the old site so that I can cleanly retire the old Octopress blog without killing old links.
Thankfully, Firebase has some easy tools for configuring redirects. These will all get baked into my firebase.json file.
A basic redirect looks like this (this would go in your firebase.json):
{
"source" : "/firebase/*",
"destination" : "https://firebase.google.com",
"type" : 302
}
We need to create a redirect entry to cover for all of the pages of the old site. Some of the articles from the old blog were mildly popular and have many inbound links to them. The first step is to gather that list of pages.
Thankfully, the old site published all of the posts to the blog/ folder. This means we can use a wildcard redirect to the old site for anything under “blog”. This should redirect all of the links we care about. If people were deep linking to things besides my blog posts they will have to update their links manually.
Eventually this may prove to be a short-sighted approach (what if I need the “blog” folder back?). I could just as easily generate specific redirects for every page in the old sitemap but that isn’t necessary at this point. I will update this post when that day comes.
After reviewing the old Octopress site, I came up with the following “good enough” redirects to cover blog, archives, and categories. I followed these instructions for “capture” redirects.
{
"hosting": {
"public": "public",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"redirects": [
{
"source" : "/blog/:post*",
"destination" : "https://2012.heygrady.com/blog/:post*",
"type" : 302
},
{
"source" : "/archives/:post*",
"destination" : "https://2012.heygrady.com/archives/:post*",
"type" : 302
},
{
"source" : "/categories/:post*",
"destination" : "https://2012.heygrady.com/categories/:post*",
"type" : 302
}
]
}
}
firebase.jsonNow that we’ve updated our configuration it can be safely deployed.
yarn deploy
I decided to move the old site to Firebase hosting as well. I had been hosting it on an old server I configured more than a decade ago. I don’t want to rely on that old server anymore.
public/ folderAt this point, visiting the blog/ folder (like this) will redirect to the old 2012 site. Hooray!
When everything appears to be working, update the new blog project in Firebase to connect “heygrady.com” and “www.heygrady.com”, and update Google Domains as instructed.
Once the DNS propagates and the certificates are issued, the site should just work.
heygrady.com and www.heygrady.com to the new site (www should redirect to heygrady.com)@ and www A records to the Firebase IP addressesnew to redirect to heygrady.com in Firebase console.