WordPress To Hugo Exporter

We’ve got a WordPress to Hugo Exporter for those of you who need to export your WordPress Site to Hugo.

Features

  • Converts all posts & pages from WordPress for use in Hugo
  • Processes shortcodes
  • Converts all post_content to Markdown Extra (using Markdownify)
  • Converts all post_meta and fields within the wp_posts table to YAML front matter for parsing by Hugo.
  • Converts all Advanced Custom Fields into front matter in your posts. May be duplicate data, but new keys.
  • Metadata is converted markdown.
  • All internal URls are converted to relative URLs.
  • Exports private posts and drafts. They are marked as drafts as well and won’t get published with Hugo.
  • Generates a config.yaml with all settings in the wp_options table
  • Automatically adds Hugo aliases, so if you have to restructure redirects are already built in

Exports

To set the right expectation, your exported content will be Hugo compatible but will only be a base to work from. All platform changes are inherently difficult, but we’ll get you most of the way there.

Basic Metadata

Your exported posts and pages will have this data transformed for use with Hugo

  • Title
  • Date
  • Featured Image
  • Content
  • Tags
  • Categories

That’s usually a large chunk of most sites. And Hugo and most themes will need this basic metadata.

Custom Fields

Custom fields are a different story. All your custom fields will be there, but most themes won’t know what to do with them. You’ll have to translate those somehow. Using your IDE to find and replace field keys names can help.

Advanced Custom Fields users should note that your fields will be stored as if you ran get_fields() on a post. So you’re ready to start theming.

Why CLI?

It’s been my experience that it just runs faster. Server speeds and setup can vary wildly. Some hosts have very short max timeouts that will cause the export to fail. Using CLI takes most of the headache away.

Recommneded Setup

You should be running the website on a local WordPress installation.

Usage with a locally hosted WordPress installation

  1. Download Bugo WP Export CLI Plugin.
  2. Place plugin zip in /wp-content/plugins/ folder
  3. Unzip the file
  4. Activate plugin in WordPress dashboard
  5. In a termainal navigate to your WordPress installation to begin using WP-CLI
  6. Type in your command. See Command-line Usage below.

Command-line Usage

wp bugo <subcommand> <directory>

Subcommand

  • export - export pages, posts and media library
  • posts - exports only posts & pages
  • media - exports the media library (preserved directories)
  • originals - exports only the original media from the media library
  • all - exports posts,pages and the media library

Directory This is your target directory. A new folder containing the export will be created here.

Example

# wp bugo all ~/Desktop

Exports posts, exports posts,pages and the media library to ~/Desktop/wp-hugo-<website>