Show HN: I made a service to convert WordPress blogs to Hugo (wp2hugo.blogdb.org)
I made this project to read a WordPress export and create the markdown files for Hugo. It'll speed up the process of moving your blog over to Hugo and let you avoid a bunch of manual work.
It came about when I was talking to somebody who was trying to move their site over and didn't want to manually copy and reformat all their posts. They had trouble finding a tool to do it, so I wrote one.
I want to make sure it's useful to people before charging them, so it'll give you a download with 3 pages and 5 blog posts converted for free and without asking for any information. If you like what you see, there is a one-time charge through Stripe to convert everything.
I hope you find it useful, and I welcome any and all feedback on it!
Thanks for reading!
44 comments
[ 4.8 ms ] story [ 115 ms ] threadEdit: 413 Request Entity Too Large.
I know but I'm still not happy about it. Also Hugo is not what I would call a WYSIWYG application like Wordpress, so...
Thanks for the 413 note! I've just upped the client_max_body_size if you want to give it a try again.
My service only converts the blog posts and pages themself and helps you get started on a conversion.
WP lets me drag/drop or upload media very very easily. Has done for years.
Hugo? or indeed most SSG's?
https://gist.github.com/lewiscollard/c6651648d1c20144ed89e16...
Copy that into your "layouts/shortcodes/image.html" and use it as
If you just want to upload it to _not_ reference it in a post/page, copy it into your `static` directory and it'll be passed through when the site is built.Hope that helps!
I think you could do this with a render hook if you want to get fancy (with the benefit that the Markdown for your posts stays as plain Markdown): https://werat.dev/blog/automatic-image-size-attributes-in-hu...
Was curious why you picked Hugo over something like Astro. I'm migrating a site off of Jekyll and have found Astro has a lot of interesting features if I want to use them but is at its heart a static site generator and seems to be a pretty easy lift to migrate to. Haven't done much evaluation of Hugo yet.
Really the reason I picked Hugo is because that's what the person I was talking to wanted. He'd only found contractors who would charge more than he wanted to pay to do a manual conversion, and said even something that just got his pages and posts over would be worthwhile to him.
I have more experience with Jekyll. In fact, I had tried to start a hosted platform with a CMS for it that I opened sourced a while back (https://github.com/symkat/MyJekyllBlog) but it never really got traction.
At this point I'm actively looking for a new job and figured getting this on Hacker News might be helpful for that.
I hadn't heard of Astro before, it looks neat!
Hopefully moving to a more actively supported static site generator will benefit us but its also a lesson to us that we need to keep track of continued support of apps we rely on. It's easy to just build and forget something and then there's a fire drill when you have to go back and change something that hasn't been re-deployed in a while.
Are you keeping URLs stable? That was tricky for me IIRC, along with RSS.
(The very trickiest bit was probably specific to me. I still have inbound links with the page in a "/?p=3" kind of query param, which I think was the WordPress default 20-odd years ago. I didn't want to make the root URL for the site non-static to handle that, so I wound up putting some JS in my index page template that checks for that kind of thing. If it spots it, it changes window.location to a specific URL that is delegated a Flask site that knows where to redirect people. Link in bio if anyone wants to see how it works. I should probably blog about it sometime!)
That's super awesome too, this is not so different under the hood, I used libxml for getting the content and pandoc for converting -- pandoc turned out to be by far the best of the tools I tried for that aspect.
It won't necessarily keep the URLs stable, they'll be made based on the title of the post.
That's a cool solution for the ?p=<id> issues, this doesn't handle it but when I've done it for for sites I host I usually use nginx's rewrite rules. I think for query rewriting you need to additionally use the map directive, but I was only handling directory vs .html and things like that.
Thank you again for commenting, I like your site!
If we are going to use JS, then you might as well put the redirects themselves in JS. Have a tiny stub of JS that detects the "/?p=xxx" case, which can then load the (presumably very large) list of redirects from a separate file and do the redirecting. That'll save you maintaining the extra service.
As for me, I moved from a Django app I made to a Hugo site, but it's pretty much the same deal. Because my Hugo site is on a "real" server (rather than e.g. GitHub Pages) I just have a giant pile of 500+ redirects in the nginx config file for the site (which is checked into the same repo as my Hugo site). It works for me.
Because isn't this just "WordPress 2 Markdown".
Unless I'm mistaken, this does not recreate your WordPress theme/template to be used in Hugo (nor nothing specific to Hugo).
It's just exporting your blog posts from WordPress database into a Markdown file format.
Note: still very useful, I just find the name confusing.
It does put your files into a Hugo directory structure and includes the smol theme. It doesn't recreate your theme, plugins, or process your images, but I also have tried to be very explicit that it just converts your pages and posts and is the starting point for a conversion.
When you put an export file through it, you'll end up on this page: https://imgur.com/a/UUMB6ve where you can download a zip or tgz of the site and you'll clearly understand what you're getting before you can choose if you want to have the remaining pages/posts converted.
0: https://www.ifwiki.org/Hugo