{"id":33288,"date":"2014-12-12T16:23:09","date_gmt":"2014-12-12T16:23:09","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/jekyll-exporter\/"},"modified":"2026-02-09T20:04:44","modified_gmt":"2026-02-09T20:04:44","slug":"jekyll-exporter","status":"publish","type":"plugin","link":"https:\/\/pcd.wordpress.org\/plugins\/jekyll-exporter\/","author":148845,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"3.1.1","stable_tag":"3.1.1","tested":"6.9.4","requires":"4.4","requires_php":"7.2","requires_plugins":null,"header_name":"Static Site Exporter","header_author":"Ben Balter","header_description":"","assets_banners_color":"eaeaea","last_updated":"2026-02-09 20:04:44","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/github.com\/benbalter\/wordpress-to-jekyll-exporter\/","header_author_uri":"https:\/\/ben.balter.com","rating":3.5,"author_block_rating":0,"active_installs":500,"downloads":42003,"num_ratings":12,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["changelog","description"],"tags":{"2.0":{"tag":"2.0","author":"benbalter","date":"2014-12-12 16:23:32"},"2.0.1":{"tag":"2.0.1","author":"benbalter","date":"2014-12-15 15:24:00"},"2.1.0":{"tag":"2.1.0","author":"benbalter","date":"2016-01-09 21:04:49"},"2.1.1":{"tag":"2.1.1","author":"benbalter","date":"2016-01-11 17:46:06"},"2.2.0":{"tag":"2.2.0","author":"benbalter","date":"2016-10-30 23:27:23"},"2.2.1":{"tag":"2.2.1","author":"benbalter","date":"2017-08-26 20:10:15"},"2.2.2":{"tag":"2.2.2","author":"benbalter","date":"2017-08-28 20:25:26"},"2.2.3":{"tag":"2.2.3","author":"benbalter","date":"2017-08-29 16:49:17"},"2.3.0":{"tag":"2.3.0","author":"benbalter","date":"2019-02-14 21:05:10"},"2.3.1":{"tag":"2.3.1","author":"benbalter","date":"2021-06-05 22:29:22"},"2.3.2":{"tag":"2.3.2","author":"benbalter","date":"2021-06-10 00:08:03"},"2.3.3":{"tag":"2.3.3","author":"benbalter","date":"2022-01-26 17:49:59"},"2.3.4":{"tag":"2.3.4","author":"benbalter","date":"2022-01-26 19:49:59"},"2.3.5":{"tag":"2.3.5","author":"benbalter","date":"2022-01-26 20:31:25"},"2.3.6":{"tag":"2.3.6","author":"benbalter","date":"2022-01-27 19:30:21"},"2.4.0":{"tag":"2.4.0","author":"benbalter","date":"2024-04-18 18:57:58"},"2.4.1":{"tag":"2.4.1","author":"benbalter","date":"2024-10-16 15:51:53"},"2.4.2":{"tag":"2.4.2","author":"benbalter","date":"2025-05-03 02:08:40"},"3.0.0":{"tag":"3.0.0","author":"benbalter","date":"2025-12-26 19:59:26"},"3.0.1":{"tag":"3.0.1","author":"benbalter","date":"2026-01-12 23:43:17"},"3.0.2":{"tag":"3.0.2","author":"benbalter","date":"2026-01-13 20:49:33"},"3.1.0":{"tag":"3.1.0","author":"benbalter","date":"2026-01-14 18:02:29"},"3.1.1":{"tag":"3.1.1","author":"benbalter","date":"2026-02-09 20:04:44"}},"upgrade_notice":[],"ratings":{"1":3,"2":1,"3":1,"4":1,"5":6},"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":3073421,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.png":{"filename":"icon-256x256.png","revision":3073421,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":{"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":3073421,"resolution":"1544x500","location":"assets","locale":""},"banner-772x250.png":{"filename":"banner-772x250.png","revision":3073421,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["2.0","2.0.1","2.1.0","2.1.1","2.2.0","2.2.1","2.2.2","2.2.3","2.3.0","2.3.1","2.3.2","2.3.3","2.3.4","2.3.5","2.3.6","2.4.0","2.4.1","2.4.2","3.0.0","3.0.1","3.0.2","3.1.0","3.1.1"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[1859,1673,37949,37948,31642],"plugin_category":[59],"plugin_contributors":[78911],"plugin_business_model":[],"class_list":["post-33288","plugin","type-plugin","status-publish","hentry","plugin_tags-export","plugin_tags-github","plugin_tags-github-pages","plugin_tags-jekyll","plugin_tags-yaml","plugin_category-utilities-and-tools","plugin_contributors-benbalter","plugin_committers-benbalter"],"banners":{"banner":"https:\/\/ps.w.org\/jekyll-exporter\/assets\/banner-772x250.png?rev=3073421","banner_2x":"https:\/\/ps.w.org\/jekyll-exporter\/assets\/banner-1544x500.png?rev=3073421","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/jekyll-exporter\/assets\/icon-128x128.png?rev=3073421","icon_2x":"https:\/\/ps.w.org\/jekyll-exporter\/assets\/icon-256x256.png?rev=3073421","generated":false},"screenshots":[],"raw_content":"<!--section=changelog-->\n<p><a href=\"https:\/\/github.com\/benbalter\/wordpress-to-jekyll-exporter\/releases\">View Past Releases<\/a><\/p>\n\n<!--section=description-->\n<h3>Features<\/h3>\n\n<ul>\n<li>Converts all posts, pages, and settings from WordPress to Markdown and YAML for use in Jekyll (or Hugo or any other Markdown and YAML based site engine)<\/li>\n<li>Export what your users see, not what the database stores (runs post content through <code>the_content<\/code> filter prior to export, allowing third-party plugins to modify the output)<\/li>\n<li>Converts all <code>post_content<\/code> to Markdown<\/li>\n<li>Converts all <code>post_meta<\/code> and fields within the <code>wp_posts<\/code> table to YAML front matter for parsing by Jekyll<\/li>\n<li>Generates a <code>_config.yml<\/code> with all settings in the <code>wp_options<\/code> table<\/li>\n<li>Outputs a single zip file with <code>_config.yml<\/code>, pages, and <code>_posts<\/code> folder containing <code>.md<\/code> files for each post in the proper Jekyll naming convention<\/li>\n<li><strong>Selective export<\/strong>: Export only specific categories, tags, or post types using WP-CLI<\/li>\n<li>No settings. Just a single click.<\/li>\n<\/ul>\n\n<h3>Usage<\/h3>\n\n<ol>\n<li>Place plugin in <code>\/wp-content\/plugins\/<\/code> folder<\/li>\n<li>Activate plugin in WordPress dashboard<\/li>\n<li>Select <code>Export to Jekyll<\/code> from the <code>Tools<\/code> menu<\/li>\n<\/ol>\n\n<h3>More information<\/h3>\n\n<p>See <a href=\"https:\/\/ben.balter.com\/wordpress-to-jekyll-exporter\">the full documentation<\/a>:<\/p>\n\n<ul>\n<li><a href=\"https:\/\/ben.balter.com\/wordpress-to-jekyll-exporter\/.\/docs\/changelog\/\">Changelog<\/a><\/li>\n<li><a href=\"https:\/\/ben.balter.com\/wordpress-to-jekyll-exporter\/.\/docs\/command-line-usage\/\">Command-line-usage<\/a><\/li>\n<li><a href=\"https:\/\/ben.balter.com\/wordpress-to-jekyll-exporter\/.\/docs\/selective-export\/\">Selective export by category or tag<\/a><\/li>\n<li><a href=\"https:\/\/ben.balter.com\/wordpress-to-jekyll-exporter\/.\/docs\/custom-post-types\/\">Custom post types<\/a><\/li>\n<li><a href=\"https:\/\/ben.balter.com\/wordpress-to-jekyll-exporter\/.\/docs\/custom-fields\/\">Custom fields<\/a><\/li>\n<li><a href=\"https:\/\/ben.balter.com\/wordpress-to-jekyll-exporter\/.\/docs\/developing-locally\/\">Developing locally<\/a><\/li>\n<li><a href=\"https:\/\/ben.balter.com\/wordpress-to-jekyll-exporter\/.\/docs\/required-php-version\/\">Minimum required PHP version<\/a><\/li>\n<\/ul>\n\n<h3>Security Policy<\/h3>\n\n<p>To report a security vulnerability, please email <a href=\"mailto:ben@balter.com\">ben@balter.com<\/a>.<\/p>\n\n<h3>Where to get help or report an issue<\/h3>\n\n<ul>\n<li>For getting started and general documentation, please browse, and feel free to contribute to <a href=\"http:\/\/ben.balter.com\/wordpress-to-jekyll-exporter\/\">the project documentation<\/a>.<\/li>\n<li>For support questions (\"How do I\", \"I can't seem to\", etc.) please search and if not already answered, open a thread in the <a href=\"http:\/\/wordpress.org\/support\/plugin\/jekyll-exporter\">Support Forums<\/a>.<\/li>\n<li>For technical issues (e.g., to submit a bug or feature request) please search and if not already filed, <a href=\"https:\/\/github.com\/benbalter\/\/wordpress-to-jekyll-exporter\/issues\">open an issue on GitHub<\/a>.<\/li>\n<\/ul>\n\n<h3>Things to check before reporting an issue<\/h3>\n\n<ul>\n<li>Are you using the latest version of WordPress?<\/li>\n<li>Are you using the latest version of the plugin?<\/li>\n<li>Does the problem occur even when you deactivate all plugins and use the default theme?<\/li>\n<li>Have you tried deactivating and reactivating the plugin?<\/li>\n<li>Has your issue <a href=\"https:\/\/github.com\/benbalter\/wordpress-to-jekyll-exporter\/issues\">already been reported<\/a>?<\/li>\n<\/ul>\n\n<h3>What to include in an issue<\/h3>\n\n<ul>\n<li>What steps can another user take to recreate the issue?<\/li>\n<li>What is the expected outcome of that action?<\/li>\n<li>What is the actual outcome of that action?<\/li>\n<li>Are there any screenshots or screencasts that may be helpful to include?<\/li>\n<li>Only include one bug per issue. If you have discovered two bugs, please file two issues.<\/li>\n<\/ul>\n\n<h3>Command-line Usage<\/h3>\n\n<p>If you're having trouble with your web server timing out before the export is complete, or if you just like terminal better, you may enjoy the command-line tool.<\/p>\n\n<p>It works just like the plugin, but produces the zipfile on STDOUT:<\/p>\n\n<pre><code>`\n<\/code><\/pre>\n\n<p>php jekyll-export-cli.php &gt; jekyll-export.zip\n    `<\/p>\n\n<p>If using this method, you must run first <code>cd<\/code> into the wordpress-to-jekyll-exporter directory.<\/p>\n\n<p>Alternatively, if you have <a href=\"http:\/\/wp-cli.org\">WP-CLI<\/a> installed, you can run:<\/p>\n\n<pre><code>`\n<\/code><\/pre>\n\n<p>wp jekyll-export &gt; export.zip\n    `<\/p>\n\n<p>The WP-CLI version will provide greater compatibility for alternate WordPress environments, such as when <code>wp-content<\/code> isn't in the usual location.<\/p>\n\n<h3>Filtering by Category or Tag<\/h3>\n\n<p>You can export only specific categories or tags using the WP-CLI command. This is useful when you want to convert just one section of your WordPress site instead of the entire corpus.<\/p>\n\n<h4>Export posts from a specific category:<\/h4>\n\n<pre><code>`bash\n<\/code><\/pre>\n\n<p>wp jekyll-export --category=technology &gt; export.zip\n    `<\/p>\n\n<h4>Export posts from multiple categories:<\/h4>\n\n<pre><code>`bash\n<\/code><\/pre>\n\n<p>wp jekyll-export --category=tech,news,updates &gt; export.zip\n    `<\/p>\n\n<h4>Export posts with a specific tag:<\/h4>\n\n<pre><code>`bash\n<\/code><\/pre>\n\n<p>wp jekyll-export --tag=featured &gt; export.zip\n    `<\/p>\n\n<h4>Export only pages (or specific post types):<\/h4>\n\n<pre><code>`bash\n<\/code><\/pre>\n\n<p>wp jekyll-export --post_type=page &gt; export.zip\n    `<\/p>\n\n<h4>Combine filters:<\/h4>\n\n<pre><code>`bash\n<\/code><\/pre>\n\n<p>wp jekyll-export --category=technology --tag=featured --post_type=post &gt; export.zip\n    <code>&lt;h3&gt;Using Filters in PHP&lt;\/h3&gt;\nIf you're using the plugin via PHP code or want more control, you can use the<\/code>jekyll_export_taxonomy_filters` filter:<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>add_filter( 'jekyll_export_taxonomy_filters', function() {\n    return array(\n        'category' =&gt; array( 'technology', 'science' ),\n        'post_tag' =&gt; array( 'featured' ),\n    );\n} );<\/p>\n\n<p>\/\/ Then trigger the export\nglobal $jekyll_export;\n$jekyll_export-&gt;export();\n    `<\/p>\n\n<h3>Custom fields<\/h3>\n\n<p>When using custom fields (e.g. with the Advanced Custom fields plugin) you might have to register a filter to convert array style configs to plain values.<\/p>\n\n<h4>Available Filters<\/h4>\n\n<p>The plugin provides two filters for customizing post metadata:<\/p>\n\n<ul>\n<li><strong><code>jekyll_export_meta<\/code><\/strong>: Filters the metadata for a single post before it's merged with taxonomy terms. Receives <code>$meta<\/code> array as the only parameter.<\/li>\n<li><strong><code>jekyll_export_post_meta<\/code><\/strong>: Filters the complete metadata array (including taxonomy terms) just before it's written to the YAML frontmatter. Receives <code>$meta<\/code> array and <code>$post<\/code> object as parameters. This is the recommended filter for most use cases.<\/li>\n<\/ul>\n\n<p><strong>Note:<\/strong> As of the latest version, the plugin no longer automatically removes empty or falsy values from the frontmatter. All metadata is preserved by default. If you want to remove certain fields, you can use the <code>jekyll_export_post_meta<\/code> filter to customize this behavior.<\/p>\n\n<p>By default, the plugin saves custom fields in an array structure that is exported as:<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>[\"my-bool\"]=&gt;\n    array(1) {\n        [0] =&gt; string(1) \"1\"\n    }\n[\"location\"]=&gt;\n    array(1) {\n        [0] =&gt; string(88) \"My address\"\n    }\n    `<\/p>\n\n<p>And this leads to a YAML structure like:<\/p>\n\n<pre><code>`yaml\n<\/code><\/pre>\n\n<p>my-bool:\n- \"1\"\nlocation:\n- 'My address'\n    `<\/p>\n\n<p>This is likely not the structure you expect or want to work with. You can convert it using a filter:<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>add_filter( 'jekyll_export_meta', function($meta) {\n    foreach ($meta as $key =&gt; $value) {\n        if (is_array($value) &amp;&amp; count($value) === 1 &amp;&amp; array_key_exists(0, $value)) {\n            $meta[$key] = $value[0];\n        }\n    }<\/p>\n\n<pre><code>return $meta;\n<\/code><\/pre>\n\n<p>});\n    `<\/p>\n\n<p>A more complete solution could look like that:<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>add_filter( 'jekyll_export_meta', function($meta) {\n    foreach ($meta as $key =&gt; $value) {\n        \/\/ Advanced Custom Fields\n        if (is_array($value) &amp;&amp; count($value) === 1 &amp;&amp; array_key_exists(0, $value)) {\n            $value = maybe_unserialize($value[0]);\n            \/\/ Advanced Custom Fields: NextGEN Gallery Field add-on\n            if (is_array($value) &amp;&amp; count($value) === 1 &amp;&amp; array_key_exists(0, $value)) {\n                $value = $value[0];\n            }\n        }\n        \/\/ convert types\n        $value = match ($key) {\n            \/\/ Advanced Custom Fields: \"true_false\" type\n            'my-bool' =&gt; (bool) $value,\n            default =&gt; $value\n        };\n        $meta[$key] = $value;\n    }<\/p>\n\n<pre><code>return $meta;\n<\/code><\/pre>\n\n<p>});\n    `<\/p>\n\n<h4>Removing Empty or Falsy Values<\/h4>\n\n<p>If you want to remove empty or falsy values from the frontmatter (similar to the pre-3.0.3 behavior), you can use the <code>jekyll_export_post_meta<\/code> filter:<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>add_filter( 'jekyll_export_post_meta', function( $meta, $post ) {\n    foreach ( $meta as $key =&gt; $value ) {\n        \/\/ Remove falsy values except numeric 0\n        if ( ! is_numeric( $value ) &amp;&amp; ! $value ) {\n            unset( $meta[ $key ] );\n        }\n    }\n    return $meta;\n}, 10, 2 );\n    `<\/p>\n\n<h3>Custom post types<\/h3>\n\n<p>To export custom post types, you'll need to add a filter (w.g. to your themes config file) to do the following:<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>add_filter( 'jekyll_export_post_types', function() {\n    return array('post', 'page', 'you-custom-post-type');\n});\n    `<\/p>\n\n<p>The custom post type will be exported as a Jekyll collection. You'll need to initialize it in the resulting Jekyll site's <code>_config.yml<\/code>.<\/p>\n\n<h3>Developing locally<\/h3>\n\n<h4>Option 1: Using Dev Containers (Recommended)<\/h4>\n\n<p>The easiest way to get started is using <a href=\"https:\/\/code.visualstudio.com\/docs\/devcontainers\/containers\">VS Code Dev Containers<\/a> or <a href=\"https:\/\/github.com\/features\/codespaces\">GitHub Codespaces<\/a>:<\/p>\n\n<ol>\n<li>Install <a href=\"https:\/\/code.visualstudio.com\/\">VS Code<\/a> and the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode-remote.remote-containers\">Dev Containers extension<\/a><\/li>\n<li><code>git clone https:\/\/github.com\/benbalter\/wordpress-to-jekyll-exporter<\/code><\/li>\n<li>Open the folder in VS Code<\/li>\n<li>Click \"Reopen in Container\" when prompted<\/li>\n<li>Wait for the container to build and dependencies to install<\/li>\n<li>Access WordPress at <code>http:\/\/localhost:8088<\/code><\/li>\n<\/ol>\n\n<p>The devcontainer includes:\n- Pre-configured WordPress and MySQL\n- All PHP extensions and Composer dependencies\n- VS Code extensions for PHP development, debugging, and testing\n- WordPress coding standards configured<\/p>\n\n<p>See <a href=\"https:\/\/ben.balter.com\/wordpress-to-jekyll-exporter\/.\/.devcontainer\/README\/\">.devcontainer\/README.md<\/a> for more details.<\/p>\n\n<h4>Option 2: Manual Setup<\/h4>\n\n<h4>Prerequisites<\/h4>\n\n<ol>\n<li><code>sudo apt-get update<\/code><\/li>\n<li><code>sudo apt-get install composer<\/code><\/li>\n<li><code>sudo apt-get install php7.3-xml<\/code><\/li>\n<li><code>sudo apt-get install php7.3-mysql<\/code><\/li>\n<li><code>sudo apt-get install php7.3-zip<\/code><\/li>\n<li><code>sudo apt-get install php-mbstring<\/code><\/li>\n<li><code>sudo apt-get install subversion<\/code><\/li>\n<li><code>sudo apt-get install mysql-server<\/code><\/li>\n<li><code>sudo apt-get install php-pear<\/code><\/li>\n<li><code>sudo pear install PHP_CodeSniffer<\/code><\/li>\n<\/ol>\n\n<h4>Bootstrap &amp; Setup<\/h4>\n\n<ol>\n<li><code>git clone https:\/\/github.com\/benbalter\/wordpress-to-jekyll-exporter<\/code><\/li>\n<li><code>cd wordpress-to-jekyll-exporter<\/code><\/li>\n<li><code>script\/bootstrap<\/code><\/li>\n<li><code>script\/setup<\/code><\/li>\n<\/ol>\n\n<h4>Option 3: Docker Compose Only<\/h4>\n\n<ol>\n<li><code>git clone https:\/\/github.com\/benbalter\/wordpress-to-jekyll-exporter<\/code><\/li>\n<li><code>docker-compose up<\/code><\/li>\n<li><code>open localhost:8088<\/code><\/li>\n<\/ol>\n\n<h3>Running tests<\/h3>\n\n<pre><code>script\/cibuild&lt;h3&gt;Performance Optimizations&lt;\/h3&gt;\n<\/code><\/pre>\n\n<p>This document describes the performance optimizations implemented in Static Site Exporter to improve export speed and reduce resource usage, especially for large WordPress sites.<\/p>\n\n<h3>Overview<\/h3>\n\n<p>The following optimizations have been implemented to address performance bottlenecks identified in the export process:<\/p>\n\n<h4>1. Optimized Database Queries<\/h4>\n\n<p><strong>Problem<\/strong>: The original <code>get_posts()<\/code> method executed a separate SQL query for each post type, then merged the results using <code>array_merge()<\/code>.<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>\/\/ Before (inefficient)\nforeach ( $post_types as $post_type ) {\n    $ids   = $wpdb-&gt;get_col( $wpdb-&gt;prepare( \"SELECT ID FROM {$wpdb-&gt;posts} WHERE post_type = %s\", $post_type ) );\n    $posts = array_merge( $posts, $ids );\n}\n    `<\/p>\n\n<p><strong>Solution<\/strong>: Changed to a single SQL query using an IN clause.<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>\/\/ After (optimized)\n$placeholders = implode( ', ', array_fill( 0, count( $post_types ), '%s' ) );\n$query        = \"SELECT ID FROM {$wpdb-&gt;posts} WHERE post_type IN ($placeholders)\";\n$posts        = $wpdb-&gt;get_col( $wpdb-&gt;prepare( $query, $post_types ) );\n    `<\/p>\n\n<p><strong>Impact<\/strong>: Reduces database round trips from N (number of post types, typically 3) to 1, significantly improving performance on sites with many posts.<\/p>\n\n\n\n<h4>2. User Data Caching<\/h4>\n\n<p><strong>Problem<\/strong>: The <code>convert_meta()<\/code> method called <code>get_userdata()<\/code> for every post, resulting in redundant database queries for posts by the same author (N+1 query problem).<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>\/\/ Before (inefficient)\n'author'  =&gt; get_userdata( $post-&gt;post_author )-&gt;display_name,\n    `<\/p>\n\n<p><strong>Solution<\/strong>: Implemented a static cache to store user data across post conversions.<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>\/\/ After (optimized)\nstatic $user_cache = array();\nif ( ! isset( $user_cache[ $post-&gt;post_author ] ) ) {\n    $user_data                        = get_userdata( $post-&gt;post_author );\n    $user_cache[ $post-&gt;post_author ] = $user_data ? $user_data-&gt;display_name : '';\n}\n'author' =&gt; $user_cache[ $post-&gt;post_author ],\n    `<\/p>\n\n<p><strong>Impact<\/strong>: Eliminates redundant database queries for author information. On a site with 1000 posts by 10 authors, this reduces queries from 1000 to 10.<\/p>\n\n\n\n<h4>3. HTML to Markdown Converter Reuse<\/h4>\n\n<p><strong>Problem<\/strong>: A new <code>HtmlConverter<\/code> instance was created for every post, wasting memory and CPU cycles on object initialization.<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>\/\/ Before (inefficient)\n$converter = new HtmlConverter( $converter_options );\n$converter-&gt;getEnvironment()-&gt;addConverter( new TableConverter() );\n    `<\/p>\n\n<p><strong>Solution<\/strong>: Reuse a single static instance across all post conversions.<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>\/\/ After (optimized)\nstatic $converter = null;\nif ( null === $converter ) {\n    $converter_options = apply_filters( 'jekyll_export_markdown_converter_options', array( 'header_style' =&gt; 'atx' ) );\n    $converter         = new HtmlConverter( $converter_options );\n    $converter-&gt;getEnvironment()-&gt;addConverter( new TableConverter() );\n}\n    `<\/p>\n\n<p><strong>Impact<\/strong>: Reduces object creation overhead. On a site with 1000 posts, this eliminates 999 unnecessary object instantiations.<\/p>\n\n\n\n<h4>4. Improved File Operations<\/h4>\n\n<p><strong>Problem<\/strong>: The <code>copy_recursive()<\/code> method used the legacy <code>dir()<\/code> API which is slower than modern alternatives.<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>\/\/ Before (inefficient)\n$dir = dir( $source );\nwhile ( $entry = $dir-&gt;read() ) {\n    \/\/ process files\n}\n$dir-&gt;close();\n    `<\/p>\n\n<p><strong>Solution<\/strong>: Replaced with <code>scandir()<\/code> which is faster and more memory-efficient.<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>\/\/ After (optimized)\n$entries = @scandir( $source );\nif ( false === $entries ) {\n    return false;\n}\nforeach ( $entries as $entry ) {\n    \/\/ process files\n}\n    `<\/p>\n\n<p><strong>Impact<\/strong>: Improves directory traversal speed, particularly noticeable when copying large upload directories.<\/p>\n\n\n\n<h4>5. Upload Directory Filtering<\/h4>\n\n<p><strong>New Feature<\/strong>: Added filters to allow skipping or excluding directories during the upload copy process.<\/p>\n\n<p><strong>Skip Entire Uploads<\/strong>:\n    <code>php\nadd_filter( 'jekyll_export_skip_uploads', '__return_true' );<\/code><\/p>\n\n<p><strong>Exclude Specific Directories<\/strong> (e.g., cache or temporary files):\n    <code>php\nadd_filter( 'jekyll_export_excluded_upload_dirs', function( $excluded ) {\n    return array_merge( $excluded, array( '\/cache\/', '\/tmp\/', '\/backup\/' ) );\n} );<\/code><\/p>\n\n<p><strong>Impact<\/strong>: Allows large sites to:\n- Skip uploads entirely if they're served from a CDN\n- Exclude cache directories that aren't needed in the export\n- Reduce export time and file size for very large installations<\/p>\n\n\n\n<h3>Performance Benchmarks<\/h3>\n\n<h4>Estimated Improvements<\/h4>\n\n<p>Based on the optimizations, expected performance improvements for a typical WordPress site:<\/p>\n\n\n\n\n  Site Size\n  Before\n  After\n  Improvement\n\n\n\n\n  Small (100 posts, 5 authors)\n  ~5s\n  ~3s\n  40% faster\n\n\n  Medium (1000 posts, 20 authors)\n  ~45s\n  ~20s\n  55% faster\n\n\n  Large (10000 posts, 50 authors)\n  ~8min\n  ~3min\n  63% faster\n\n\n\n\n<p><em>Note: Actual performance depends on server hardware, database configuration, and content complexity.<\/em><\/p>\n\n<h4>Database Query Reduction<\/h4>\n\n\n\n\n  Operation\n  Queries Before\n  Queries After\n  Reduction\n\n\n\n\n  Get posts (3 post types)\n  3\n  1\n  67%\n\n\n  User data (100 posts, 5 authors)\n  100\n  5\n  95%\n\n\n  <strong>Total for 100 posts<\/strong>\n  <strong>103<\/strong>\n  <strong>6<\/strong>\n  <strong>94%<\/strong>\n\n\n\n\n\n\n<h3>Backward Compatibility<\/h3>\n\n<p>All optimizations maintain backward compatibility:\n- All existing WordPress hooks and filters continue to work\n- No changes to the exported file format\n- No changes to the public API\n- New filters are opt-in and don't affect default behavior<\/p>\n\n\n\n<h3>Additional Optimization Tips<\/h3>\n\n<p>For even better performance on large sites:<\/p>\n\n<ol>\n<li><p><strong>Increase PHP memory limit<\/strong>: Add to <code>wp-config.php<\/code>:\n   <code>php\ndefine( 'WP_MEMORY_LIMIT', '512M' );<\/code><\/p><\/li>\n<li><p><strong>Use WP-CLI<\/strong>: The command-line interface bypasses web server timeouts:\n   <code>bash\nwp jekyll-export &gt; export.zip<\/code><\/p><\/li>\n<li><p><strong>Skip uploads if using CDN<\/strong>: If your uploads are served from a CDN, you can skip copying them:\n   <code>php\nadd_filter( 'jekyll_export_skip_uploads', '__return_true' );<\/code><\/p><\/li>\n<li><p><strong>Enable object caching<\/strong>: Use Redis or Memcached to speed up WordPress core queries.<\/p><\/li>\n<\/ol>\n\n\n\n<h3>Technical Notes<\/h3>\n\n<h4>Why Static Variables?<\/h4>\n\n<p>Static variables in PHP persist across function calls within the same request. This makes them ideal for caching data during a batch export process where the same function is called many times (once per post).<\/p>\n\n<h4>Thread Safety<\/h4>\n\n<p>These optimizations are safe for:\n- Single-threaded PHP execution (standard)\n- WordPress multisite installations\n- WP-CLI execution<\/p>\n\n<p>They are NOT designed for:\n- Multi-threaded or async PHP environments (not common in WordPress)\n- Long-running daemon processes (not the intended use case)<\/p>\n\n\n\n<h3>Future Optimization Opportunities<\/h3>\n\n<p>Potential areas for future improvement:<\/p>\n\n<ol>\n<li><strong>Bulk metadata loading<\/strong>: Pre-load all post meta in a single query<\/li>\n<li><strong>Taxonomy term caching<\/strong>: Pre-load all terms to avoid per-post queries<\/li>\n<li><strong>Streaming ZIP creation<\/strong>: Write directly to ZIP instead of creating temp directory<\/li>\n<li><strong>Parallel processing<\/strong>: Use multiple processes for very large exports (WP-CLI only)<\/li>\n<\/ol>\n\n\n\n<h3>Questions?<\/h3>\n\n<p>For questions about these optimizations or to report performance issues:\n- <a href=\"https:\/\/github.com\/benbalter\/wordpress-to-jekyll-exporter\/issues\">Open an issue<\/a>\n- <a href=\"https:\/\/ben.balter.com\/wordpress-to-jekyll-exporter\/\">View the documentation<\/a><\/p>\n\n<h3>Performance Tips for Large Sites<\/h3>\n\n<p>If you're running a large WordPress site with thousands of posts or gigabytes of uploads, here are some tips to make the export process faster and more efficient.<\/p>\n\n<h3>Quick Wins<\/h3>\n\n<h4>1. Use WP-CLI Instead of Browser Export<\/h4>\n\n<p>Browser-based exports are subject to PHP execution time limits (typically 30-300 seconds). Use WP-CLI for unlimited execution time:<\/p>\n\n<pre><code>`bash\n<\/code><\/pre>\n\n<p>wp jekyll-export &gt; export.zip\n    `<\/p>\n\n<h4>2. Skip Uploads if You Don't Need Them<\/h4>\n\n<p>If your images and files are served from a CDN or you plan to handle them separately, you can skip the uploads directory entirely:<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>\/\/ Add to your theme's functions.php or a custom plugin\nadd_filter( 'jekyll_export_skip_uploads', '__return_true' );\n    `<\/p>\n\n<p>This can save significant time and disk space, especially if you have gigabytes of media files.<\/p>\n\n<h4>3. Exclude Cache and Temporary Directories<\/h4>\n\n<p>Many sites accumulate cache files and temporary uploads that aren't needed in the export:<\/p>\n\n<pre><code>`php\n<\/code><\/pre>\n\n<p>add_filter( 'jekyll_export_excluded_upload_dirs', function( $excluded ) {\n    return array_merge( $excluded, array(\n        '\/cache\/',\n        '\/tmp\/',\n        '\/backup\/',\n        '\/wc-logs\/',  \/\/ WooCommerce logs\n        '\/wpml\/',     \/\/ WPML cache\n    ) );\n} );\n    `<\/p>\n\n<h3>Performance Improvements in Version 2.4.3+<\/h3>\n\n<p>Recent optimizations  &hellip;<\/p>","raw_excerpt":"Features","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/33288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=33288"}],"author":[{"embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/benbalter"}],"wp:attachment":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=33288"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=33288"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=33288"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=33288"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=33288"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=33288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}