Giter Club home page Giter Club logo

wordpress-wp2grav-markdown-exporter's Introduction

WP2Grav - Export your Wordpress Site into getgrav.org content structure

Export your Wordpress posts, pages and more into a markdown content structure for Grav - A Modern Flat-File CMS

Description

Ready to move to Grav - A Modern Flat-File CMS?

This plugin allows you to export your posts, pages, authors, tags and categories into a markdown file based content structure for getgrav.org

The exporter creates a folder structure using the slugs of Wordpress - so you will keep your Urls!

Depending on your Wordpress installation (theme, add-ons) you will need to add some custom code loaded before the export process and review & edit the generated file set.

Supported content types and meta data

Currently following content types are supported

  • pages
  • posts
  • authors

Following meta data is supported:

  • publish data
  • published status
  • authors
  • categories
  • tags

To add more content types start with the export() function in /wp-content/plugins/wp2grav/includes/wp2grav-admin.class.php to see how to add more types.

Images, Links

Urls of images and links are not touched by the export process. So all references will be kept like they are in Wordpress and converted into markdown.

Images: You might either move the wordpress uploads directory into the root of your grav installation or manually move all referenced media files into a location of your choice and use the search & replace function of your IDE change the references.

Links: You might need to use the search & replace function of your IDE to fix the link urls in the exported content files.

Export location

The export will be stored in

/wp-content/uploads/wp2grav/export

qTranslate support

The multi-language add-ons qtranslate and qtranslate slug are supported to export into the getgrav.org multi-language file format keeping language specific slugs.

Note

Consider this plugin as "good enough to do the job", but not more ;)

Installation

Upload the WP2Grav plugin to your site into

wp-content/plugins/

and activate it through the Wordpress Administration.

Configuration

the exporter should work with the default settings, but there are a number of options to tweak with:

set a master page to hold blog posts

in getgrav.org you might want to store all blog posts within a page, e.g. 01.blog page. You can achieve this by creating a new page in wordpress (this page will be exported as a folder where all blog post files are stored) and assign the postId (you find it in the url while editing the page) to constant

define('WP2GRAV_BLOG_MASTER_PAGE_ID', '<pageId>');

located in

wp-content/plugins/wp2grav/includes/wp2grav.config.php

export batch size / php timeouts

to avoid php timeout issues for large sites you can change the batch size defined in constant:

define('WP2GRAV_EXPORT_BATCH_SIZE', 100);

located in

wp-content/plugins/wp2grav/includes/wp2grav.config.php

the exporter will load itself again until all content is exported.

add custom code

rename

/wp-content/plugins/wp2grav/includes/_theme_init.php

into

/wp-content/plugins/wp2grav/includes/theme_init.php

add the necessary code to be loaded to the function themeInit() which is called before the export process.

adopt export files format

adopt the format of the exported grav markdown files by editing the export templates:

Page:
/wp-content/plugins/wp2grav/templates/export/page.md

Post:
/wp-content/plugins/wp2grav/templates/export/post.md

Author:
/wp-content/plugins/wp2grav/templates/export/author.md

Tips

  • the exporter will not overwrite already generated files. So if you want to generate a certain subset of pages again just delete them from the export directory and start the exporter.
  • you can export all pages and then change the template configuration in the page template. When you delete a certain folder and run the exporter again the markdown files are generated based on the new page template)
  • you can use your IDE to search / replace within the folder structure to change configuration values
  • check the files categories.txt and tags.txt - these files contain all categories and tags and make it easy to clean up this data, e.g. to remove similar / duplicate values

qtranslate fixes

export date issue

open

/wp-content/plugins/qtranslate/qtranslate_core.php

in

function qtrans_dateFromPostForCurrentLanguage()

change around line 460

return qtrans_strftime(qtrans_convertDateFormat($format), mysql2date('U',$post->post_date), $old_date, $before, $after);

into (remove $before, $after)

return qtrans_strftime(qtrans_convertDateFormat($format), mysql2date('U',$post->post_date), $old_date);

Credits

thanks to following add-ons for inspiration:

StaticWP

WordPress CMS Tree Page View

wordpress-wp2grav-markdown-exporter's People

Contributors

cord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wordpress-wp2grav-markdown-exporter's Issues

Unable to activate plugin in WordPress 6.2 w/ PHP 8.2

So far I've run into two fatal errors:

Fatal error: __autoload() is no longer supported, use spl_autoload_register() instead in /wp-content/plugins/wp2grav/vendor/htmlpurifier/library/HTMLPurifier.autoload.php on line 17

Warning: Undefined array key "wp2grav-action" in /wp-content/plugins/wp2grav/wp2grav.php on line 65

Doesn't work

Hi,

I was very happy to find that there is a plugin that finally allows me to get rid of my WordPress installation and move to something light-weight and fast.
Unfortunately, after installing the plugin and pressing the "Go for it" button, nothing happens. I only see a blank page.

Let me know if I can help with providing version information, debug output etc
I am very much interested in getting this plugin working on my system...

No valid plugins?

When installing from Wordpress.org on Wordpress 4.4.1:
The package could not be installed. No valid plugins were found.

Does not work export

I'm trying to make an export from WP 4.5
I get a page with the text:

Generate Page 01.sample-page /
Permalink: http://wiki.bank.psbst.ru/sample-page/
Page-id 2

It does not depend on what ID I'm using
Inside the export folder there are 2 files: categories.txt and tags.txt
Also there is a folder with authors and an empty folder 01.SiteName

Works well

But I need to add my stuffs into theme_init.php and I realy dont know how to do...
So if anybody have time to help ...
I would like to export _wp_attached_file
I should paid for it...
Thanks

This plugin still functions for WP v6

(Jan 2023), this may be relevant to new readers, I just exported my whole site including pages and multiple blog posts and it worked nicely. I will have to correct some urls to images etc and rebuild image galleries. I think it ignores featured img but keeps in body img intact. Imho it's still very good (I am using on WP v6). NB when you import to your blog items make sure to keep refreshing cache in order to see the posts displayed in your blog list page.

Things I had to do:

  • make sure you upload the actual plugin folder, its nesting about 3 levels in :)
  • the long folder name of the zip download causes issues when extracting (on Win). Shorten this to wp2grav
  • upload this folder to /wp-content/plugins folder via ftp
  • your export will show up in the wp-content/blog folder, go there via ftp and download that to your desktop. If you run multisite this is probably named blogs.dir
  • import the entries (each folder is a post item) to your blog items folder in Grav
  • if you have date options enabled in Grav, the posts will display according to the accurate poste date as this is included in the item frontmatter

hope some of this helps others.

Not working autoinstall and posts export

WP2GRAV_BLOG_MASTER_PAGE_ID' was defined.
In every folder must be 1 md file. In blogg (BLOG_MASTER_PAGE_ID) - 1 file too. No posts. Other pages seems ok

Could be install just from repository. Zip or "Search" are not.

WordPress 4.4.1

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.