Bogdan Bujdea
Bogdan Bujdea

Bogdan Bujdea

Migrating your Hashnode blog to a new domain

Migrating your Hashnode blog to a new domain

From thewindev.net to bogdanbujdea.dev

Subscribe to my newsletter and never miss my upcoming articles

I've been thinking for some time to migrate my blog to a new domain and yesterday I finally did it (I'll talk about the reason for this in another post). My main concern was transferring the blog posts from thewindev.net to bogdanbujdea.dev, and redirecting users from the old posts to the new domain. This way, if anyone clicked on an article from the old domain they would be redirected to the new article instead of seeing a 404 page.

Here's how I did it:

1. Register a new domain

2. Migrate Hashnode blog posts, the hard way

3. Migrate Hashnode blog posts, the easy way

4. Redirect posts from old domain to new one

5. Conclusions


1. Register a new domain

I decided to register a .dev domain from Google. This step is fairly easy so I won't go into details here.

2. Migrate Hashnode blog posts (the hard way)

Here is where things got tricky. I thought that there would be a way to export my blog posts and import them into another account, so I created a new Hashnode account where I added my Google domain (bogdanbujdea.dev). Then I went to the Export page from the Hashnode Dashboard and I exported the blog posts to a json file.

Export Hashnode blog posts

This only took a few seconds (I have only 18 posts so far 🤣). Once the file was downloaded I went to the Import page where I saw these options:

Import blog posts into Hashnode

Clearly I don't need Medium or Dev.to, so I looked at the other two options. The first one I tried was the Bulk markdown importer

Bulk Markdown Importer Import a zip file containing posts in markdown format. Your zip should contain a .md file for each post. Importer reads the following properties from the markdown frontmatter: title, slug, date, and image.

This one requires a zip file with .md files, but Hashnode exported a json file, so clearly this will not work. Then I remembered that I use GitHub backup for my Hashnode account and in there I have .md files for each blog post. So I went to GitHub, downloaded a zip with all the blog posts in .md format, and then I tried to upload it to Hashnode. The result:

Import error

The problem is that Hashnode expects a .md file that looks like this:

Sample post for import

And here's how my GitHub .md files look like:

Github backup file

As you can see, the backup doesn't contain the blog post title, date, etc. One way would be to create a tool that modifies my .md files to add this information, and while this would've been fun as a side project, I didn't had so much time so I decided to try the next option.

Unfortunately, the RSS import was not a good solution because it didn't kept the structure of the article so I had to decide if I want to manually edit each one or go with something else, so I picked the latter.

3. Migrate Hashnode blog posts (the easy way)

As I mentioned earlier, I created another Hashnode account for my new domain, so I thought I could switch the domains:

image.png

There's no "switch domain" option in Hashnode, so I did it like this:

  • I went to my initial Hashnode account and deleted the domain thewindev.net

image.png

  • I did the same for the second Hashnode account
  • I went to my initial Hashnode account and added the domain bogdanbujdea.dev
  • I went to the second Hashnode account and added the domain thewindev.net

Now, my blog posts stayed where they were, on the same Hashnode account, but the domain was changed and it took less than a minute. The only problem I had was that the analytics were transferred as well, so I have 0 views on my blog again 😅.

4. Redirect posts from old domain to new one

Thankfully, Hashnode offers an option to redirect users in the Advanced settings page.

image.png

As you can see in the screenshot, I have two redirects. The second one is the easiest to understand, as it will redirect every user that opens an old link to the new domain. You can try going to this article thewindev.net/overview-of-my-smart-home-the.. and see that you will get redirected to bogdanbujdea.dev/overview-of-my-smart-home-..

The only thing that's missing is a redirect for the root of the site, so that if you go to thewindev.net you will automatically go to bogdanbujdea.dev Unfortunately, this is not possible with the current redirect settings in Hashnode, so I found an acceptable workaround.

image.png

This is the only blog post on my old domain, so when someone tries to click on it, Hashnode will redirect them to my new domain. I achieved this by adding a redirect from /moved-to-bogdanbujdeadev to bogdanbujdea.dev

5. Conclusions

To be honest, I would've preferred they had an option for this so I don't have to do everything manually, but I understand this is not something you might do everyday so I'm ok with it, Hashnode should focus on more important features :) The only downside that I found is that I can't redirect from my home page and the fact that I lost the analytics, but this is acceptable for me because I relied on Google Analytics anyway.

 
Share this
Proudly part of