WordPress -> Hugo migration: still no good way

I looked at Migrate to Hugo | Hugo a few years back and gave up after realizing that the migration tools were mostly half-baked, abandoned, or required a jump via Jekyll.

There still isn’t a simple reliable (and ideally Go-based) tool that can take a WordPress XML export of the website and map it to a Hugo website faithfully.

Before I attempt to build one, is it that hard to build one?

There is no, and never will be a perfect took for migration to Hugo from Wordpress (or more rather migration from Wordpress into Markdown files will be more accurate), and this is not Hugo or tools fault.

The problem is with Wordpress at its code.

It may be easy to create migration tool from Pure Wordpress, without any additions, no extra plugins and functionalities, but people barely using only pure Wordpress.

Adding single plugin/funcionality to do extra bits with simple posts will add additional code to the output of each page, this code need to be interpreted/converted in some how. This means the tool would need to consider various scenerios, and there will be too many to to consider.

I migrated couple Wordpress pages and it always been a time consuming but it was worth it. Look more into converting Wordpress into markdown, as than its easier to work on content in markdown and actual files as images/attachments in any platform, including Hugo.

If you are in position/ability to build tool that will work for your Wordpress site, it may, but also may not work for other Wordpress site. Its hard to say if is hard to build one as it all depend.

What I would suggest you is to watch this first:

2 Likes

That sounds very bleak. In my experience, there is a WP plugin to export posts as markdown files. That works for posts and pages. It does not work 100% for custom post types (which is something I am working on; in the end, it’s how you retrieve the content). However, it’s enough to get a start.

On the other side, for me personally, no world can convert everything to everything. It’s a decision you fell when you started your website. You need to know what your website is about and what it’s features have to be.

The thing to think about is this: If it was WordPress before, why would you want it to be Hugo now? Was WordPress wrong? Do you have a website that is static and used a dynamic website creation tool for it until now? Many people “switching” from WP to Hugo (IMHO) don’t understand what they are doing.

4 Likes

Afaik, this does not preserve the relative page links

Thanks for sharing the video.
I just finished watching it.
Hugo is written in Go.
I am surprised that there is no single tool in Go to do this migration that I can use as a basis for my blog.
I would have enhanced that tool in case it was missing support for some plugins.

As to why Go, simply because Hugo is written in Go as well.
I am choosing Hugo over Jekyll because I believe that Hugo would last longer and the code would be more maintainable that Jekyll or other static site generators.

GitHub - CloudCannon/staticshape: A CLI tool to convert a static site into an SSG site to be used as a baseline seems to have been built and dumped.
The repo does not even have CI setup.
It does not inspire confidence in any form.

Imagine this in such way. What happens when you succesfully migrate from Wordpress to Hugo. Unless you are professionally creating websites and Wordpress to Hugo miration is your daily routine, after you done it, you will forget about it and never use.

I migrate few websites and got same feeling. Migrate Wordpress to Markdown with as many tools as is available and comare results and see which one working for you better. Than do hard work.

Of course, having a tool would be good, but maintaining it, if you not involved in migration as a part of your job will be difficult. This is why the tools that you find will quickly go out of use once Wordpress evolves.

I know this is my opinion, but looking on that from my perspective, and perspective of spending time on creating tool that will be used once or twice, until site is migrated, is not good way.

Wordpress is not Go, hence it doesn’t matter if you make tool in Go or not. The hard job is to get your data in correct way from Wordpress, then you can make whatever is needed to process “your data” for your needs.

Thats conclude to my way of thinking. Once you used tool to your need, and there is no longer need to use it, thats what will be happening.

As @davidsneighbour suggest, and what I insist to day, start with export to markdown and then carry your work there.

2 Likes

At the core what you mean is: Wordpress is appalling.
We can all agree on this. I had to do that… twice. No plugin that I can remember, yet the page structure differed. Because it makes sense…

That’s true.
Most migration tools are labor of love.
Others like migrate to Jekyll even WordPress extensions exist!

I’ve migrated a couple of Drupal sites to Hugo, not dissimilar. I think the Readme on the drupal2hugo page sums up the problem well:

“Think of this tool as a starting point for automating your site migration. I think it would be pretty futile to try to create a one-size-fits-all migration tool.”

Web based CMS like Wordpress and Drupal are essentially tool kits to build a custom website - as is Hugo. Each website ends up different and there never will be an easy to use migration tool for that reason.

That said I think I can offer some migration advice:

  • Take an iterative approach. Expect to have to run the migration tool and do any post processing repeatedly, improving it each time.
  • Choose the existing migration tool that gets you closest to what you want (if you have the expertise modify the tool to better fit your target site).
  • Don’t forget about command line tools like Sed and Awk for tweaking the output from the migration tool.
  • Collect any useful sed and awk commands you build in a shell script so you can re-run them as you develop.

Finally, in my experience these big shifts in tooling are opportunities to make improvements and changes to the site – you rarely want a 1:1 migration anyway.

1 Like

I wrote a fair bit of custom code and have a migration tool that’s 80% of the way there now.

1 Like

I made the tool public - GitHub - ashishb/wp2hugo: The best WordPress to Hugo migrator (written in Go)
I primarily used my website (https://ashishb.net) as a test bed (https://v2.ashishb.net)

The tool handles quite a few quirky things right like maintaining RSS GUID, embedded media, post URLs, WordPress Captions, YouTube embeds, draft dates etc.
I am confident that this is one of the best tools right now to migrate WordPress to Hugo

1 Like

You should explain how to install it too… I am familiar with hugo, I have wordpress sites, but I am not familiar with Go and the billions of ways to install programs, so don’t expect people to guess which one works :upside_down_face: :slightly_smiling_face:

You should explain how to install it too

/facepalm
Added the section on usage to README.
Further, created a binary release, so, no Go code compilation is required.

1 Like

Well I’m at fault too, I didn’t think of reading “make: go: No such file or directory”, meaning that the compiler wasn’t installed. Manual compilations make me queasy every times.

drm@B8-97-5A-F9-E4-87 ~/w/s/wp2hugo (main) [SIGHUP]> doas make
go build -v -o bin/wp2hugo ./cmd/wp2hugo
# cd /home/drm/wp2hugo; git status --porcelain
fatal: detected dubious ownership in repository at ‘/home/drm/wp2hugo’
To add an exception for this directory, call:
git config --global --add safe.directory /home/drm/wp2hugo
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
make: *** [Makefile:4: build_debug] Error 1
drm@B8-97-5A-F9-E4-87 ~/w/s/wp2hugo (main) [2]> make
go build -v -o bin/wp2hugo ./cmd/wp2hugo

Can’t see wp2hugo anywhere on my disk, nor on github:

Binary can be downloaded from here (scroll to bottom).
If you want to compile from source.

$ git clone git@github.com:ashishb/wp2hugo.git
$ cd wp2hugo/src/wp2hugo
$ make build_prod
# `./cmd/wp2hugo` will contain the binary

compilation still creates nothing… I’ve opened an issue.

I watched a video and did quite well.

However, the script listed in the vid is not the original script. The dev told me. Go back to the original fork
I think this is the original and active.

After you get the conversion working you can clone my website
It has almost all the same things as a typical wp blog, pictures, and rss and other things.
I did some nonos where I modified directly into the theme. So just be aware of that.

Thanks. I looked at GitHub - lonekorean/wordpress-export-to-markdown: Converts a WordPress export XML file into Markdown files.. It is a bit incomplete. For example, it won’t migrate GUID correctly.

I’m not sure what you mean by GUID (in the context of basic web pages), but if you do indeed have a simple website worthy of being static, I recommend you make an issue, the author is active and willing to help make it work. Catch the devs for these tools while you can. Also watch the video too. i was able to make it work to some degree but I did have write some substitution scripts with gpt+ in dart. Those scripts are in my script folder.

While HUGO can replace most WP websites, most WP websites are simple in nature and don’t require a dynamic website.

BTW: When I ran the wp conversion script, i did so on a digital ocean throw away Ubuntu server, installing the dependencies on the fly.