# Exporting from wordpress...?

I have spent far too long experimenting with wordpress plugins for exporting to jekyll, and to hugo, as well as plain wordpress export to xml, and wp2hugo.go. This last one looks very promising - but I’ve no idea how to use it. The command as explained here:

go run wp2hugo.go wp-export.xml


doesn’t seem to actually create any content. It creates a “hugo new” directory structure, all of which are empty, and a very barebones config.toml.

Or is there a better way?

I think Bob Volte is on this site as well, but I don’t know his nick.

I think the important part is to understand that you might want to include the tools for Jekyll as well. Getting the content into Markdown files is the hard part.

As it is I have an xml file (created by Wordpress Export) and a zip file (created by the Wordpress to Hugo plugin), but I’m not sure how to incorporate the files into my hugo blog. The xml file seems to produce an error whenever I use it, but the zip file is happily full of *.md files, images etc, all in their various directories depending on time of creation. Should I unzip and ignore the directory structure, then put all *.md files into “content” and all media files into “static”? Or is there a better way?

The .zip file is the contents of your content directory. Create a hugo site, put the zip contents into content and start hugoserver. I did it several times with wp2hugo and all contents were there.

I’ve tried both ExitWP and the “WordPress to Hugo Exporter” (which you have to manually install from the GitHub repo).

The plugin is good and it worked first time. ExitWP also worked but seems to create more code that has to be edited than the exporter plugin does.

Note, however, that neither of these are a magic bullet.

For starters, none of my TAGS came across using either method. Though the Categories came over just fine.

Also, while you get your uploads (images, etc), they end up (at least with the plugin) in a separate folder that you need to integrate and the references in any posts remain pointed back to your original WordPress site so you have to change all of those - I used VSCode with search and replace in files.

I think that both converters add URL frontmatter variables so that you can easily retain your original URL’s for posts which is a tremendous benefit over something like Jekyll.

Not so good is that I ended up with a bunch of “excerpt” frontmatter variables that really should have been converted to “description” which I use in my converted site. Another search/replace fixed that up.

Then there were the code blocks. These really didn’t convert at all well so I ended up with a load of code tags in my markdown which got default formatting instead of proper highlighting. I’m having to go through those by hand though I probably could have automated it using Notepad++ or PowerShell or such-like. I didn’t have so many that it was that big an issue and I got them all done in about an hour.

Dated archive “folders” are also problematic. Hugo has no facility for this - you get it pretty well automatically in WordPress. There are various examples for workarounds but they all seem rather involved and I haven’t got far enough down my fixup list yet to resolve this.

Feed URL’s are another issue since WordPress’s are in the form /feed but Hugo uses index.rss - as I am using Netlify for hosting, I’ve simply used their rewrite feature to fix this up.

I needed a new theme of course and 10/10 to Hugo for making themes pretty easy - I’ve been recreating something that looks a little like the WordPress Twenty-Sixteen theme that I was using before.

I’ve had to reproduce some sidebar widgets, particularly the Twitter feed and some “follow me” icons. Not difficult.

The default styles for pagination are a bit naff and I still need to improve that but again, not too hard to do.

My menu’s took a lot of effort to get right - but that is partly due to how I wanted to structure my sections.

My WP theme has a banner image that changes on page reload/change - I’ll add that back in when I implement lazy loading but it will have to be done on the front-end of course.

I still have a long list of things to do but actually the basics are all there and the site could go live as is.

The preview site is here: https://confident-carson-5eac42.netlify.com

I’d say that it has taken me about a week of mainly evening work though that hasn’t been every night. There are a few really weird gotcha’s in Hugo but overall I’m finding it very productive and sane.

I appreciate that not only are these tools mostly new, but use of Hugo seems to assume a fair degree of computing experience. I don’t mind this at all - as long as I can ask stupid questions when I get stuck. However, I do note that even after the export, there will be a lot of manual cleaning to do. For my posts, one of the biggest issues is the conversion of equations with the Wordpress QuickLaTeX plugin to MathJax.

Currently equations are exported as images:

<img src="http://numbersandshapes.net/wp-content/ql-cache/quicklatex.com-
59b3f7a1e8f94f54596ae6db007f8a18_l3.png" class="ql-img-inline-formula
quicklatex-auto-format" alt="&#121;&#61;&#76;&#40;&#120;&#41;"
title="Rendered by QuickLaTeX.com" height="18" width="68"
style="vertical-align: -4px;" />


when all I want is the html ascii codes to be returned as their symbols:

$y=L(x)$


When I have the time and mental energy (hah!) I’ll attempt to write a small program to do just this: to trawl through a markdown file and replace every such image with its corresponding equation as text. I’ll probably do it in Python - simply because it’s the language I know best - unless I would be better off picking up a smattering of go.

Personally, I would prefer it if people created script tools in languages reasonably likely to already be on my PC. I mainly use Node.JS but also have Python. One of the great benefits of Hugo to me is not having to install go.

I am very interested in understanding why wp2hugo did not convert your WordPress export file. If your blog does not contain any confidential or classified information could you please send me your export file via e-mail? My address is first name dot last-name at Google.

Thanks.