James Cridland

Removing my posts from Medium, but keeping the URLs working

Eurgh, Medium. It was a decent service. I liked the “friend link” that I could send people, which skipped the paywall and let them read the article in full.

Then, they added lots of cruft, and changed lots of it, and changed the “friend link” to require registration to read an article. The content on Medium was also mostly AI-generated rubbish, which looked bad.

So, today, I switched everything away. And hopefully all the URLs still work.

I used blog.james.cridland.net as my Medium subdomain. So I figured that I could switch all my posts out of Medium, and then switch this domain to point to them on my own website (this one), and hopefully not lose any SEO.

I use Hugo to make this website. It’s on static web hosting via Amazon AWS. I wondered if it would be possible.

How to transfer your posts

I downloaded my posts from Medium - which you can do at this address, using the link “Download your information”. The posts are in a subdomain marked “posts”, in an HTML format.

I used medium-2-md to transfer those files from HTML to MarkDown, which this website uses. It doesn’t work properly using the latest version of Node on MacOS, but if you use an older version of Node, it’ll work OK.

So, that’s the posts switched over.

Aliases

I set my URLs by having a folder for each year, and Hugo makes the URLs out of the filename.

I used sed -i '.bak' 's/slug/aliases/g' * and sed -i '.bak' 's/\/@jamesrcridland//g' * which changes the “slug” in the metadata of the files to “aliases”, and remove my username from the beginning of it. That ought to make an alias which means that this link with the old Medium path forwards nicely to this link where it lives now.

That appears to work, so that’s nice.

Then, I used the rename command to programmatically rename the files into the right folder, and remove the UID at the end of it.

I’m left with a sensible-looking list of posts with sensible-looking filenames.

I still needed to go through them - some were replies to other posts on Medium, so those went; and images didn’t properly convert through (Medium’s export didn’t actually work for most images). I removed most of the images that weren’t vital, since I didn’t want to spend a lot of time on this, and half an hour of visiting the pages on Medium sufficed for the posts that did. I removed a few posts that didn’t make much sense any more.

But I still needed the old URLs to work.

Redirects

With the aliases feature, I can redirect the path - but not change the domain.

Medium URLs started with the https://blog.james.cridland.net/ domain. My real blog uses https://james.cridland.net/ instead.

That meant a new AWS S3 bucket and Cloudfront combo which redirects from one domain to another which seemed to work quite well, in actual fact. Surprisingly, I managed to achieve this without any dead-ends in Amazon’s documentation. Yay, go me.

And now…

It works!

https://blog.james.cridland.net/making-a-scalable-google-analytics-alternative-for-pageviews-on-aws-c38edac89cd7 …goes through a slightly less than optimal two redirects (one a 301, one a 302, confusingly) but it does resolve on the same post on my proper blog, and Medium is no longer in the way. All that using static website hosting that is, to all intents and purposes, entirely free.

Good.

Yes, this website still looks pretty horrible: that’s partially because I don’t understand Hugo properly yet, and also because I don’t have a design bone in my body. But at least it’s mine now.