GithubHelp home page GithubHelp logo

wttw / wordpress-export Goto Github PK

View Code? Open in Web Editor NEW
6.0 4.0 1.0 18 KB

Suck posts from WordPress via the API and save them as markdown files

License: BSD 2-Clause "Simplified" License

Go 100.00%

wordpress-export's Introduction

wordpress-export

Suck posts from WordPress via the API and save them as markdown files

Features

  • Works entirely via the WordPress API, no need to install anything in WordPress
  • Fetches only public content, so no authentication needed
  • Fetches posts, authors, tags and categories and saves them as one markdown file per post
  • Includes tags, categories and authors in the markdown frontmatter
  • Exports content usable by any markdown file based CMS or site generator, such as Gatsby or Netlify CMS
  • No size limits, it handles thousands of posts
  • Fetches images and documents each post links to and saves them alongside the inedx.md file, rewriting links to point to that local copy
  • Support fetching only a sample of posts, for faster builds during development
  • It can add static yaml to the frontmatter of each post, so you can extend the schema easily

Usage

To fetch all posts and assets from your blog, and save them as a tree in a directory "output":

wordpress-export https://your-blog-host.com

To fetch the 20 newest posts, saving them as MDX files with featured post and draft settings added:

wordpress-export --sample=20 --postfile=index.mdx --frontmatter=frontmatter.yml

where frontmatter.yml contains

featuredPost: false
draft: false

Other flags:

Usage: wordpress-export [flags] <your blog url>
      --api string           Base URL of the WordPress API
      --assets string        Copy assets under this path (default "/wp-content/uploads/")
      --frontmatter string   Read additional frontmatter from this file
  -h, --help                 Show this help
      --log string           Log progress to this file
      --meta                 save tags, categories and authors
  -o, --output string        Save results to this directory (default "./output")
      --postfile string      The filename for each post (default "index.md")
      --prefix string        
  -q, --quiet                Don't print progress
      --sample int           Only retrieve this many posts
      --silent               Don't print progress or warnings
  -V, --version              Show version

Installation

Download the file from the github release page, for your operating system, unzip it and put it somewhere on your path. (If you're on Windows you can open a command prompt, cd to the directory where you unzipped it and run it from there.)

Compilation

git clone github.com/wttw/wordpress-export
cd wordpress-export
go build

Missing Features

It only exports published posts, not drafts. It doesn't export pages, comments or anything other than posts, tags, categories and authors.

I'll probably add support for comments once I work out whether I'm using StaticMan or Schnack or something else on my blog.

Support

Put any issues or requests as a github issue. I'll read issues but I'm not committing to fix everything. Pull requests welcome.

If you find it useful, buy me a coffee. ko-fi

wordpress-export's People

Contributors

wttw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

wprobot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.