[WordPress] 外掛分享: Jekyll Exporter

WordPress 外掛 Jekyll Exporter 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Jekyll Exporter」是 2014-12-11 上架。
  • 目前有 800 個安裝啟用數。
  • 上一次更新是 2025-05-03,距離現在已有 1 天。
  • 外掛最低要求 WordPress 4.4 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 7.2 以上。
  • 有 11 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

benbalter |

外掛標籤

yaml | export | Github | jekyll | github pages |

內容簡介

nclude information relevant to the issue you are reporting.

功能

將所有文章、頁面和 WordPress 設定轉換為 Markdown 和 YAML 格式,可用於 Jekyll(或 Hugo 或任何其他基於 Markdown 和 YAML 的網站引擎)
輸出的內容為用戶查看的內容,而非資料庫中存儲的內容(在導出之前,通過 the_content 附加外掛運行文章內容,從而允許第三方插件修改輸出內容)
將所有 post_content 轉換為 Markdown
將所有 post_meta 和 wp_posts 表格中的欄位轉換為 YAML 前置資料以便 Jekyll 排序
生成包含 wp_options 表格中所有設定的 _config.yml
輸出單個 zip 檔,其中包含 _config.yml、頁面和 _posts 文件夾,其中包含符合 Jekyll 命名慣例的每篇文章的 .md 檔案
無需進行任何設置,只需一個單擊即可完成

使用方法

將插件放置在 /wp-content/plugins/ 文件夾中
在 WordPress 控制台中啟用插件
從 工具 菜單中選擇 導出到 Jekyll

更多信息

參閱完整文檔:

更新日誌
命令行用法
自定文章類型
本地開發
最低要求的 PHP 版本

安全政策

如需報告安全漏洞,請發送電子郵件至 [email protected]

獲得幫助或報告問題的位置

如需開始使用和一般文檔,請瀏覽並隨時貢獻該項目文檔
對於支援問題(例如“我該怎麼做”的問題),請搜索並如未有答案,請在支援論壇中開啟一個主題。
對於技術問題(例如提交錯誤或功能請求),請搜索並如未創建,請在 GitHub 上開啟問題。

報告問題前的檢查事項

您是否使用最新版本的 WordPress?
您是否使用最新版本的插件?
即使停用所有外掛並使用默認主題,問題是否仍然發生?
您是否嘗試過停用並重新啟用該插件?
是否已報告您的問題?

在問題中包括哪些內容

其他使用者可採取哪些步驟以重新生成問題?
該操作的預期結果是什麼?
實際結果是什麼?
是否有任何屏幕截圖或屏幕錄像可以添加?
僅包含與您報告的問題相關的信息。

原文外掛簡介

Features

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)
Export what your users see, not what the database stores (runs post content through the_content filter prior to export, allowing third-party plugins to modify the output)
Converts all post_content to Markdown
Converts all post_meta and fields within the wp_posts table to YAML front matter for parsing by Jekyll
Generates a _config.yml with all settings in the wp_options table
Outputs a single zip file with _config.yml, pages, and _posts folder containing .md files for each post in the proper Jekyll naming convention
No settings. Just a single click.

Usage

Place plugin in /wp-content/plugins/ folder
Activate plugin in WordPress dashboard
Select Export to Jekyll from the Tools menu

More information
See the full documentation:

Changelog
Command-line-usage
Custom post types
Custom fields
Developing locally
Minimum required PHP version

Security Policy
To report a security vulnerability, please email [email protected].
Where to get help or report an issue

For getting started and general documentation, please browse, and feel free to contribute to the project documentation.
For support questions (“How do I”, “I can’t seem to”, etc.) please search and if not already answered, open a thread in the Support Forums.
For technical issues (e.g., to submit a bug or feature request) please search and if not already filed, open an issue on GitHub.

Things to check before reporting an issue

Are you using the latest version of WordPress?
Are you using the latest version of the plugin?
Does the problem occur even when you deactivate all plugins and use the default theme?
Have you tried deactivating and reactivating the plugin?
Has your issue already been reported?

What to include in an issue

What steps can another user take to recreate the issue?
What is the expected outcome of that action?
What is the actual outcome of that action?
Are there any screenshots or screencasts that may be helpful to include?
Only include one bug per issue. If you have discovered two bugs, please file two issues.

Command-line Usage
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.
It works just like the plugin, but produces the zipfile on STDOUT:
`

php jekyll-export-cli.php > jekyll-export.zip
`
If using this method, you must run first cd into the wordpress-to-jekyll-exporter directory.
Alternatively, if you have WP-CLI installed, you can run:
`

wp jekyll-export > export.zip
`
The WP-CLI version will provide greater compatibility for alternate WordPress environments, such as when wp-content isn’t in the usual location.
Custom fields
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.
By default, the plugin saves custom fields in an array structure that is exported as:
`php

[“my-bool”]=>
array(1) {
[0] => string(1) “1”
}
[“location”]=>
array(1) {
[0] => string(88) “My address”
}
`
And this leads to a YAML structure like:
`yaml

my-bool:
– “1”
location:
– ‘My address’
`
This is likely not the structure you expect or want to work with. You can convert it using a filter:
`php

add_filter( ‘jekyll_export_meta’, function($meta) {
foreach ($meta as $key => $value) {
if (is_array($value) && count($value) === 1 && array_key_exists(0, $value)) {
$meta[$key] = $value[0];
}
}
return $meta;

});
`
A more complete solution could look like that:
`php

add_filter( ‘jekyll_export_meta’, function($meta) {
foreach ($meta as $key => $value) {
// Advanced Custom Fields
if (is_array($value) && count($value) === 1 && array_key_exists(0, $value)) {
$value = maybe_unserialize($value[0]);
// Advanced Custom Fields: NextGEN Gallery Field add-on
if (is_array($value) && count($value) === 1 && array_key_exists(0, $value)) {
$value = $value[0];
}
}
// convert types
$value = match ($key) {
// Advanced Custom Fields: “true_false” type
‘my-bool’ => (bool) $value,
default => $value
};
$meta[$key] = $value;
}
return $meta;

});
`
Custom post types
To export custom post types, you’ll need to add a filter (w.g. to your themes config file) to do the following:
`php

add_filter( ‘jekyll_export_post_types’, function() {
return array(‘post’, ‘page’, ‘you-custom-post-type’);
});
`
The custom post type will be exported as a Jekyll collection. You’ll need to initialize it in the resulting Jekyll site’s _config.yml.
Developing locally
Prerequisites

sudo apt-get update
sudo apt-get install composer
sudo apt-get install php7.3-xml
sudo apt-get install php7.3-mysql
sudo apt-get install php7.3-zip
sudo apt-get install php-mbstring
sudo apt-get install subversion
sudo apt-get install mysql-server
sudo apt-get install php-pear
sudo pear install PHP_CodeSniffer

Bootstrap & Setup

git clone https://github.com/benbalter/wordpress-to-jekyll-exporter
cd wordpress-to-jekyll-exporter
script/bootstrap
script/setup

Running tests
script/cibuild

Testing locally via Docker

1. git clone https://github.com/benbalter/wordpress-to-jekyll-exporter
2. docker-compose up
3. open localhost:8088
Minimum required PHP version
Many shared hosts may use an outdated version of PHP by default. WordPress to Jekyll Export requires PHP 5.6 or greater.
If you get an error message that looks like unexpected T_STRING, unexpected '[' or expecting T_CONSTANT_ENCAPSED_STRING, you need to update your PHP version. In a shared hosting environment, you should be able to change the version of PHP used by simply toggling the setting in the host’s control panel.
PHP 5.4 lost support from the PHP project itself in 2015. You’ll need to be running at least PHP 5.5 which adds namespace support (the reason it’s breaking), but I’d recommend at least 7.3 (or the latest your host supports) as it’s the oldest supported version.
How to determine which version of PHP you’re running

Try this plugin
Follow WordPress’s tutorial or this wikihow

How to upgrade your version of PHP
If you are using a shared hosting environment, upgrading to a newer version of PHP should be a matter of changing a setting in your host’s control panel. You’ll have to follow your host specific documentation to determine how to access it or where the setting lives. Check out this list of common hosts for more details.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Jekyll Exporter」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


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 | trunk |

延伸相關外掛(你可能也想知道)

文章
Filter
Apply Filters
Mastodon