ashishb / wp2hugo

The best WordPress to Hugo migrator (written in Go)
Other
15 stars 2 forks source link
hugo hugo-utility

WordPress to Hugo Static site migrator

Build Go

Lint Go Lint Markdown Validate Go code formatting

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.

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

Usage

Binary

Now, run this

$ wp2hugo
Usage of wp2hugo:
  -download-media
   download media files embedded in the WordPress content
  -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 the write the Hugo generated data to (default "/tmp")
  -source string
   file path to the source WordPress XML file

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`

Goals of wp2hugo

  1. [x] Migrate posts
  2. [x] Migrate pages
  3. [x] Migrate tags
  4. [x] Migrate categories
  5. [x] Migrate all the URL including media URLs correctly
  6. [x] Migrate iframe(s) like YouTube embeds
  7. [x] Migrate "Excerpt"
  8. [x] Migrate "catlist"
  9. [x] Set WordPress homepage correctly
  10. [x] Migrate RSS feed with existing UUIDs, so that entries appear the same - this is really important for anyone with a significant feed following, see more details of a failed migration
  11. [x] favicon.ico
  12. [x] YouTube embeds
  13. [x] Google Map embed via a custom short code googlemaps
  14. [x] Migrate caption (WordPress) to figure (Hugo)
  15. [x] Migrate "Show more..." of WordPress -> Summary in Hugo
  16. [x] Support for parallax blur (similar to WordPress Advanced Backgrounds)
  17. [x] Migrate WordPress table of content -> Hugo
  18. [x] Custom font - defaults to Lexend
  19. [x] Use draft date as a fallback date for draft posts
  20. [x] Maintain the draft status for draft and pending posts
  21. [x] Migrate code blocks correctly - migrate existing code class information if available
  22. [x] Download embedded photos while maintaining relative URLs
  23. [x] Map WordPress's feed.xml to Hugo's feed.xml
  24. [x] WordPress footnotes
  25. [ ] Featured images - I tried this WordPress plugin but featured images are simply not exported

Why existing tools don't work

Note:

  1. To migrate comments, use Remark42