WordPress to Hugo Static site migrator




This is the best migrator for migrating WordPress export to Hugo.
It handles several weird edge cases that I encountered while trying to migrate my personal website to Hugo-based site.
While this primarily targets Hugo-based code generation, one can use it to convert WordPress blogs to Markdown-based files that can be used with other systems,
for example, Mkdocs or Jekyll.
The following sites have migrated using wp2hugo
- ashishb.net
- inliniac.net
- blog.polarweasel.org
- open-bio.org - more details from Bastian Greshake Tzovaras
- Virtual Andy
- bjørn:johansen
- xf.is
- retro.moe
- Marcelo Fernandez (in Spanish)
- Mountain Water (Chinese Traditional)
- Hit To Key
- Chuyển địa chỉ
- Cynarski.dev (Polish)
- It's a Binary World 2.0
- The Legal Beaver
- Deuts Log
- cloudowski
- Population: One
- Aurélien Pierre Engineering
- Spinning Code
- ITTY
- Sean Graham
- skyboo.net
- Tim's tech thoughts (tsmith.co)
Commercial usage
I want this project to be as widely accessible as possible, while still funding the development costs.
This project is completely free for non-commercial and personal usage.
Commercial usage is restricted via a license.
Feel free to contact me if you want to license this commercially.
What does wp2hugo do better than other migration tools
- wp2hugo is distributed as a single and portable binary executable, requiring no installation and no dependencies. The binary is compiled code (written in Go), which provides much better performance than scripted tools.
- It can run locally on your computer, or on a server with shell access, and process the WordPress XML export file. This makes it able to migrate very large blogs in a matter of minutes, while other migration tools (e.g., those running server-side PHP code, as WordPress plugins) may time out, overflow RAM, overload the server, and fail completely on shared hosting.
- It migrates all post metadata like GUID, custom fields, taxonomies, and more, so you retain all of your original posts' information, even hidden from the user front-end. (Posts front-matters may need some manual cleanup after migration)
- It converts a large range of native WordPress shortcodes and Gutenberg blocks to Hugo shortcodes.
- It fully imports WordPress media library (files and metadata) and fully supports WordPress galleries (legacy and Gutenberg), which makes it particularly well-suited for photo blogs.
- It supports translated pages and hierarchical pages, and custom post types.
Usage
Binary
- Install hugo, verify it is
v0.146 or later with hugo version command
- Download the
wp2hugo tool from releases
- Export your WordPress website via
Tools -> Export in your admin dashboard
- Let's say the downloaded file is
wordpress-export.xml generate the website using $ wp2hugo --source wordpress-export.xml --download-media
$ wp2hugo
Usage of wp2hugo:
--authors string
CSV list of author name(s), if provided, only posts by these authors will be processed (using author slug)
--color-log-output
enable colored log output, set false to structured JSON log (default true)
--continue-on-media-download-error
continue processing even if one or more media downloads fail
--content-date-folder-structure string
organize posts/pages by publish date: flat, year, or year-month (default "flat")
--download-media
download media files embedded in the WordPress content
--download-all
download all media files from the WordPress library, whether embedded in content or not
--font string
custom font for the output website (default "Lexend")
--media-cache-dir string
dir path to cache the downloaded media files (default "/tmp/wp2hugo-cache")
--output string
dir path to write the Hugo-generated data to (default "/tmp")
--source string
file path to the source WordPress XML file
--custom-post-types string
CSV list of additional WordPress custom post types to import (using type slug)
Build from source
$ git clone git@github.com:ashishb/wp2hugo.git
$ cd wp2hugo/src/wp2hugo
$ make build_prod
# `./bin/wp2hugo` will contain the binary and you can use it as `$ ./bin/wp2hugo --source wordpress-export.xml --download-media`
Installation via Package Managers

Documentation
More details on the documentation.
Goals of wp2hugo
Migrate post types, taxonomies, and their archive pages
- [x] Migrate posts
- [x] Migrate pages in a hierarchical way, using Hugo page bundles,
- [x] Migrate tags, categories and custom taxonomies for all types of posts,
- [x] Set the WordPress homepage correctly
- [x] Create WordPress author page
- [x] Migrate WPML translated posts, pages, and custom post types that use the URL parameter scheme (switch the WPML language URL option prior to exporting your blog content to XML),
- [x] Migrate any arbitrary WordPress custom post type and store them into their own
/content/post-type subfolder (hierarchical custom posts are fully supported):
- Avada FAQ and Portfolios types are supported natively,
- Woocommerce products and product variations types are supported natively,
- user can specify a CSV list of arbitrary post types, using the
--custom-post-types argument when calling the executable. Only post types that have a publishing status (<wp:status> in export XML) matching one of the values of native posts are supported.
Migrate comments
Provided you don't want to accept new comments, old comments are automatically migrated for all post types (posts, pages and custom). You will need to insert the provided snippet into your relevant theme's single.html template. See the documentation.
Migrate permalinks
- [x] Migrate all the URLs, including media URL,s correctly
- [x] Generate Nginx config containing GUID -> relative URL mapping
- [x] Migrate the RSS feed with existing UUIDs, so that entries appear the same - this is important for anyone with a significant feed following, see more details of a failed migration
- [x] Map WordPress's RSS
feed.xml to Hugo's RSS feed.xml
Migrate post content and shortcodes
- [x] Migrate page excerpt
- [x] Migrate "Show more..." of WordPress ->
Summary in Hugo
- [x] Migrate List Category posts(catlist)
- [x] Migrate WordPress table of content -> Hugo
- [x] Migrate code blocks correctly - migrate existing code class information if available
- Migrate embeds:
- [x] Migrate iframe(s) like YouTube embeds
- [x] Migrate YouTube embeds
- [x] Migrate WordPress-style plain-text YouTube embeds in the post body
- [x] Migrate WP YouTube Lyte YouTube embeds
- [x] Migrate Google Map embed via a custom shortcode
googlemaps
- [x] Migrate GitHub gists
- Migrate WordPress shortcodes:
- [x] Migrate WordPress [caption] shortcode to Hugo's {{< figure >}})
- [x] Migrate WordPress [audio] shortcode)
- [x] Migrate Wordpress [gallery] shortcode, including empty Gallery
- Migrate Gutenberg blocks and features:
- [x] Migrate WordPress footnotes
- [x] Migrate Youtube embed Gutenberg blocks
- [x] Migrate image and gallery Gutenberg blocks
More details on the documentation.
Migrate post metadata and attributes
- [x] Maintain the draft status for draft and pending posts
- [x] Use draft date as a fallback date for draft posts
- [x] Featured images - export featured image associations with pages and posts correctly
- [x] WordPress Post formats
- [x] WordPress Custom fields, including PHP array deserialization for fields using them
Migrate media attachments
- [x] Migrate favicon.ico
- [x] Migrate
wp-content/uploads images embedded in pages to Hugo static files while maintaining relative URLs
- [x] Migrate external images (on different hosts) to Hugo static files
- [x] Optionally import all media attachments from WordPress library
- [x] Import user-defined attachment titles into a Hugo database into
/data/library.yaml
Misc
- [x] Ability to filter posts by author(s), useful for WordPress multi-site migrations
- [x] Custom font - defaults to Lexend
- [x] Support for parallax blur backgrounds (similar to WordPress Advanced Backgrounds)
Hugo Manager
This repository contains an experimental tool, hugomanager.
I use this tool for the automatic generation of URLs from the title as well as for knowing which blog posts are still
marked as drafts or which ones are scheduled to be published soon.
You can build that via
src/wp2hugo $ make build_hugo_manager
...
```bash
src/wp2hugo $ ./bin/hugomanager
A tool for managing Hugo sites e.g. adding URL suggestions, generating site status summary etc.
Usage:
hugomanage