Git Product home page Git Product logo

wordpress-export-to-markdown's Introduction

wordpress-export-to-markdown

Converts a WordPress export XML file into Markdown files.

Useful if you want to migrate from WordPress to a static site generator (Gatsby, Hugo, Jekyll, etc.).

Saves each post as a separate file with appropriate frontmatter. Also saves attached images and (optionally) any additional images found in post body content. Posts and images can be saved into a variety of folder structures.

Quick Start

You'll need:

Open your terminal to this package's directory. Run npm install and then node index.js.

This will create an /output folder filled with your posts and images.

Customization

You can use command line arguments to control options for how the script runs. For example, this will give you Jekyll-style output in terms of folder structure and filenames:

node index.js --postfolders=false --prefixdate=true

--input

  • Type: String
  • Default: export.xml

The file to parse. This should be the WordPress export XML file that you downloaded.

--output

  • Type: String
  • Default: output

The output directory where Markdown and image files will be saved.

--yearmonthfolders

  • Type: Boolean
  • Default: false

Whether or not to organize output files into year and month folders.

/output
    /2017
        /01
        /02
    /2018
        /01

--yearfolders

  • Type: Boolean
  • Default: false

Whether or not to organize output files into year folders.

/output
    /2017
    /2018

--postfolders

  • Type: Boolean
  • Default: true

Whether or not to save files and images into post folders.

If true, the post slug is used for the folder name and the post's Markdown file is named index.md. Each post folder will have its own /images folder.

/output
    /first-post
        /images
            potato.png
        index.md
    /oh-look-another-post
        /images
            cat1.gif
            cat2.gif
        index.md

If false, the post slug is used to name the post's Markdown file. These files will be side-by-side and images will go into a shared /images folder.

/output
    /images
        cat1.gif
        cat2.gif
        potato.png
    first-post.md
    oh-look-another-post.md

Either way, this can be combined with with --yearmonthfolderes and --yearfolders, in which case the above output will be organized under the appropriate year and month folders.

--prefixdate

  • Type: Boolean
  • Default: false

Whether or not to prepend the post date to the post slug when naming a post's folder or file.

If --postfolders is true, this affects the folder.

/output
    /2017-01-14-first-post
        index.md
    /2017-01-23-oh-look-another-post
        index.md

If --postfolders is false, this affects the file.

/output
    2017-01-14-first-post.md
    2017-01-23-oh-look-another-post.md

--saveimages

  • Type: Boolean
  • Default: true

Whether or not to download and save images attached to posts. Generally speaking, these are images that were added by dragging/dropping or clicking Add Media or Set Featured Image when editing a post in WordPress. Images are saved into /images. See --postfolders for more details.

--addcontentimages

  • Type: Boolean
  • Default: false

Whether or not to also include images scraped from <img> tags in post body content. These images are downloaded and saved along with other images as dictated by --saveimages. The <img> tags are updated to point to where the images are saved.

wordpress-export-to-markdown's People

Contributors

lonekorean avatar divinedominion avatar superted17 avatar

Watchers

James Cloos avatar

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.