---
title: Inquirer.js
date: 2025-01-17T15:47:02Z
modified: 2026-05-15T10:53:41Z
permalink: "https://dgw.ltd/2025/01/17/inquirer-js/"
type: post
status: publish
excerpt: "Moving content from WordPress to a static site often means wrestling with complex command-line syntax. We found a cleaner way: using Inquirer.js to streamline the entire export process into one simple, interactive command."
wpid: 483
categories:
  - Code
featured_image: "https://dgw.ltd/wp-content/uploads/2025/01/inquirer-vid.jpg"
featured_image_alt: Screenshot of a video showing some terminal commands to run an export process for blog posts
---

An increasing number of posts appears to be focusing on how to get content \*out\* of WordPress. Lol. Well needs must etc.

Last time we looked at [styles](https://dgw.ltd/2025/01/10/wp-scss/). So this week how about some content wrangling? The goal is to get the WordPress page/post content into our Eleventy instance for processing.

Firstly 11ty/import [basically just does this](https://github.com/11ty/eleventy-import) wooo.

Now that’s a great option, but we might want a little more control over the output, maybe we want to get some ACF fields or some post meta for example, or do some data manipulation. I saw this blog post at some point [Taking WordPress to Eleventy](https://www.joshcanhelp.com/taking-wordpress-to-eleventy/) from Josh which used a custom WP-CLI command `wp wptomd /path/to/output` and does a bunch of stuff around cleaning and processing the data. Here is the [git repo](https://github.com/joshcanhelp/wordpress-to-markdown).

Now this is great for our needs, it queries the WordPress instance for the selected post type and structures the Markdown metadata format, permalink, title, date, etc. So this is where we could maybe add [Computed Data](https://www.11ty.dev/docs/data-computed/) here for example if we wanted to extract some post meta. I edited the plugin a little for my own needs, but mostly it’s the one that Josh built.

So effectively we have two commands now:

Eleventy


```json
npx @11ty/import wordpress example.com --format=markdown --output=dist
```

WP-to-MD


```json
wp wptomd /folder/ --post_type=page --file_type=md
```

Nice. Both build out a folder of markdown of html files for our browsing pleasure.

However, I wanted this to be bit more configurable so I don’t have to remember all the syntax for the various commands for each import/export method. At some point I stumbled on this post from Bob Monsour – [The node CLI scripts of my dreams](https://bobmonsour.com/blog/node-cli-of-my-dreams/), about something called [Inquirer.js](https://www.npmjs.com/package/inquirer). This was exactly what I needed, via the command line I could simply run `npm run inquirer` and run through a bunch of options to configure my export. It’s also really fun. Here is the [code in full](https://github.com/dogwonder/dgwltd-theme/blob/main/scripts/inquirer.mjs).

And a little video showing us the goodness.

This runs and spits out our content of choice in a specified folder for

Here is the output of one of the markdown files for the wp-to-md process.


```twig
---
title: "Sample Page"
layout: "layouts/markdown.njk"
excerpt: ""
date: 2025-01-06 16:05:57
modified: 2025-01-06 16:05:57
file_type: md
permalink: sample-page.html
tags: []
featured_img: 
wpid: 2
---

# Sample Page

This is an example page. It’s different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:

> Hi there! I’m a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin’ caught in the rain.)

…or something like this:

> The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.

As a new WordPress user, you should go to [your dashboard](http://) to delete this page and create new pages for your content. Have fun!
```

So there we are, via one command to rule them all where I can get a bunch of content for reuse, recycle, reduce.