Exporting My Blog from WordPress to Hugo: How I Made It Work

beatriz camaleao EqmNwhdSSRw unsplash scaled
Genx Avatar
Share This:

Exporting articles from WordPress and importing them to Hugo was harder than I thought. Some tools didn’t work, so I had to find my own way. If you’re thinking about moving your blog, this story might help.

The Problem With the Usual Tools

First, I tried some regular tools to move my WordPress blog to Hugo.

But these didn’t work well for me. Here’s what went wrong:

  • WordPress to Hugo Exporter returned an error when exporting.
  • My site had custom post types. These are special posts that are not regular blog posts or pages. The regular tools did not allow me to move them over.

Using ExitWP-for-Hugo

Since the easy way didn’t work, I tried another step.

I exported my blog from WordPress as an XML file.

Then I used a tool called exitwp-for-hugo. This tool takes the big XML file and splits it into smaller files for Hugo, the .md files for each of my articles.

1. Fixing Custom Post Types

Exitwp-for-hugo did not recognize my custom post types. I wanted all my blog stuff, not just regular posts.

So I had to open the exitwp.py script and find the part that decides which posts to take.

I added my custom post types to its list.

Now it moved everything I needed.

2. Fixing the Front Matter

Hugo likes to have a certain kind of front matter at the top of files.

The tool wrote front matter with three dashes (). Hugo likes three plus signs (+++).

So, I had to edit the script again so that Exitwp-for-hugo exports it in latest Hugo style.

Now Hugo could read my files with no problems.

Tips For Anyone Moving to Hugo

  • If the exporter plugin runs properly, use the exporter plugin. For me, the plugin didn’t work, so that is why I had to use this alternative method.
  • Check if you have custom post types. If you do, downloading exitwp-for-hugo and customizing it to your needs will do the trick.
  • Make sure the front matter in your new files matches what Hugo needs.
  • Run your Hugo site in localhost (test) mode to catch any errors.
  • Always keep a backup before you start, just in case.

What I Learned

Exporting articles from WordPress to Hugo isn’t always easy.

But if you’re willing to change a few things and check your files, you can do it. You can even ask AI to help editing the script for you.

It helped me learn more about how command line and hugo works and how to fix things.

If you’re trying this and get stuck, you can always search for help or ask questions online.

Related Posts

Genx

in , ,

Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

four × 5 =

Webmention: Have you posted a response to this article? Let me know the URL: