My friend Eric has been working on a project called Outreach For Taiwan for the last five years. It's been a serious labor of love where he travels around to different colleges during his (very limited) vacation days, and gives talks on topics ranging from culture and identity to history and politics. Educating people about Taiwan is something that means a lot to me, so I love and support what he's doing. Recently, the project was losing momentum so I offered to be Eric's official sounding board -- a person to bounce ideas off of. Sometimes you just need an ear or someone asking you questions to stay on track. I'm not sure the project itself has benefited much from my presence, but it's been personally fulfilling to be more 'in the loop' on all things Taiwan.
Anyway, to the web development part. I wanted to experiment with Gatsby and the Netlify CMS over my holiday break and decided that creating a mock Outreach For Taiwan website would be a fun project.
I used the gatsby netlify starter and had everything running in no time. I loved Gatsby's documentation, both the quick start guide and tutorial was well-written and easy to follow. Once the starter was up, I decided it was important to import all existing Outreach For Taiwan blog posts. Don't ask me why, I think I just wanted the satisfaction of 'seeing' all the posts and my whole motivation for this was to try something new and have fun. This led to figuring out how to export wordpress posts into markdown and front matter.
And that's when I discovered this helpful tool...
Hugo is static site generator written in golang. Wordpress is a tool for remote access to your server ;-) ❗️Contributions welcome!
WordPress to Hugo Exporter
Hugo a static site generator written in GoLang: https://gohugo.io
This repo is based on https://github.com/benbalter/wordpress-to-jekyll-exporter
One-click WordPress plugin that converts all posts, pages, taxonomies, metadata and settings to Markdown and YAML which can be dropped into Hugo.
- Converts all posts, pages, and settings from WordPress for use in Hugo
- Export what your users see, not what the database stores (runs post content
the_contentfilter prior to export, allowing third-party plugins to modify the output)
- Converts all
post_contentto Markdown Extra (using Markdownify)
- Converts all
post_metaand fields within the
wp_poststable to YAML front matter for parsing by Hugo.
- Exports optionally
commentsas part of their posts. This features needs to be enabled manually by editing the PHP source code. See file hugo-export.php at line ~40.
- Export private posts and drafts. They are marked as drafts as well and won't get published…
Per the readme, I needed a local instance of wordpress on my machine to install the plugin. Since I've never setup wordpress before, I decided to go the docker route.
Docker-based WordPress Stack
Docker4WordPress is a set of docker images optimized for WordPress. Use docker-compose.yml file from this repository to spin up a local environment for WordPress on Linux, macOS and Windows.
- Read the docs on how to use
- Follow @wodbycloud for future announcements
- Join community slack to ask questions
The WordPress stack consist of the following containers:
|PHP||7.3, 7.2, 7.1, 5.6||
|MariaDB||10.3, 10.2, 10.1||
|PostgreSQL||11, 10, 9.x||
|Node.js||10, 8, 6||
|Solr||7.7, 7.6, 7.5, 6.6, 5.5||
It took a little time for me to get the instance set up because I'd never touched docker before but once it was up, exporting the posts to markdown was super straight forward. The trickiest part was realizing that I needed to zip up the files in the repo and upload it as a plugin on wordpress. I should probably submit a PR in the readme to make that crystal clear -- it seems quite obvious in hindsight but figuring that out took much longer than I want to admit.
Holiday time took over the rest of my break so that's all I accomplished. But that's ok! My goal was to get a taste of technologies I don't use on the daily, and this did exactly that. Perhaps on my next break I'll try to get further with this, or try building another mock Outreach For Taiwan site with a totally different set of tools.