Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



14 Commits

Repository files navigation

WP2Grav - Export your Wordpress Site into content structure

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


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

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


qTranslate support

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


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


Upload the WP2Grav plugin to your site into


and activate it through the Wordpress Administration.


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 you might want to store all blog posts within a page, e.g. 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


export batch size / php timeouts

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


located in


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

add custom code





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:





  • 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




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);


thanks to following add-ons for inspiration:


WordPress CMS Tree Page View


Wordpress Plugin to export sites into grav content structure






No releases published


No packages published