Static HTML AI Exporter
WordPress static HTML export, AI infographic generation, WebP optimization, and knowledge API plugin
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/shotaueyama/static-html-ai/archive/refs/heads/main.zipStatic HTML AI Exporter is a WordPress plugin that exports public WordPress pages as static HTML, optimizes image delivery, generates SEO-visible HTML infographics with Gemini, and provides a knowledge graph/API workflow for content reuse.
This README is written in Japanese first, followed by English.
日本語
概要
Static HTML AI Exporter は、WordPress の公開ページを静的 HTML として出力し、通常 URL で高速配信するためのプラグインです。投稿・固定ページ・カテゴリ・タグ・アーカイブなどを HTML 化し、画像の WebP 変換、Gemini による HTML インフォグラフィック生成、ナレッジ登録、外部ナレッジ API、管理画面アシスタントを提供します。
主な機能
- 公開済み URL を静的 HTML として出力
- 通常 URL のまま静的 HTML を配信
- 投稿・固定ページごとの個別 HTML 生成
- JPEG/PNG 画像の WebP キャッシュ変換
- 静的 HTML 内の
src、srcset、poster、CSSurl(...)の WebP パス差し替え - Gemini API を使った HTML/CSS インフォグラフィック生成
- iframe を使わない SEO 認識可能なインフォグラフィック挿入
- ブロックエディタ内でのインフォグラフィックプレビューと挿入
- Markdown ファイルからのインフォグラフィック生成
- 投稿本文をチャンク化してナレッジ登録
- キーワードとつながりによるナレッジグラフ管理
- 外部ナレッジ API と API キー管理
- 登録済みナレッジを参照する管理画面アシスタント
- WP-CLI によるインベントリ作成とエクスポート
必要環境
- WordPress 6.2 以上
- PHP 7.4 以上
- 静的 HTML を書き込めるサーバーディレクトリ
- WebP 変換を使う場合は GD または Imagick の WebP 対応
- Gemini 機能を使う場合は Google Gemini API キー
- ナレッジ Embedding 機能を使う場合は OpenAI API キー
- pgvector 検索を使う場合は PostgreSQL + pgvector
インストール
static-html-aiディレクトリをwp-content/plugins/に配置します。- WordPress 管理画面でプラグインを有効化します。
ツール > Static HTML AIを開きます。- 出力先パス、公開ベース URL、必要な API キー、モデル設定を保存します。
生成開始を押すか、WP-CLI でエクスポートします。
Gemini API キーと OpenAI API キーは、管理画面に保存する代わりに wp-config.php の定数で指定できます。
define( 'STATIC_HTML_AI_GEMINI_API_KEY', 'your-gemini-api-key' );
define( 'STATIC_HTML_AI_OPENAI_API_KEY', 'your-openai-api-key' );
公開リポジトリやテーマファイルには実際の API キーを保存しないでください。
静的 HTML 出力
管理画面の ツール > Static HTML AI から、公開済みページをまとめて静的 HTML にできます。対象はトップページ、投稿、固定ページ、カテゴリ、タグ、アーカイブ、ページネーション、サイトマップなどです。
生成物は releases/{job_id} に作成され、成功後に current へ反映されます。シンボリックリンクが使えない環境では、検証済み成果物を公開フォルダへ同期します。
投稿編集画面または固定ページ編集画面では、サイドバーの 静的HTML出力状況 からそのページだけを HTML 生成できます。
通常 URL 配信
静的 HTML は /service/example/ のような通常の WordPress URL で配信できます。サーバーの .htaccess 配信が効かない場合に備えて、プラグイン内フォールバックや実 URL 配置による配信にも対応しています。
WebP 最適化
投稿編集画面からページ単位、管理画面からサイト全体の画像を WebP キャッシュへ変換できます。元画像と投稿本文は変更しません。静的 HTML 生成時に、変換済み WebP が存在する画像だけパスを差し替えます。
変換に失敗した画像は元画像を維持するため、リンク切れを避けられます。
インフォグラフィック生成
投稿・固定ページの編集画面から、Gemini を使って本文に基づく HTML インフォグラフィックを生成できます。生成結果は iframe ではなく通常の HTML/CSS として挿入されるため、検索エンジンにも認識されます。
CSS は専用の親クラス配下にスコープされ、部分リセット CSS によりテーマ CSS の影響を抑えます。script、外部アセット、イベント属性など危険な要素は保存前に除去されます。
ナレッジ登録
投稿編集画面の ナレッジに登録 から、記事を見出しごとに分割し、各章を要約してチャンクとして登録できます。ナレッジ管理画面では、メモ、キーワード、つながりを確認・編集できます。
ナレッジグループは WordPress の投稿カテゴリーと同期する設計です。API キー発行画面では、特定グループまたは すべてのグループ を対象にできます。
ナレッジ API
ナレッジAPI 画面で API キーを発行できます。外部システムから登録済みナレッジを検索したり、ナレッジを追加したりできます。
API キーは作成直後だけ表示されます。紛失した場合は新しいキーを作成してください。
認証ヘッダー:
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Automata 互換 API:
POST /wp-json/static-html-ai/v1/external/knowledge/search
POST /wp-json/static-html-ai/v1/external/knowledge/fragments
旧形式 API:
POST /wp-json/static-html-ai/v1/knowledge-external
WP-CLI
wp static-html-ai inventory
wp static-html-ai export --target=/absolute/path/to/static-root
wp static-html-ai infographic regenerate --post_type=post
セキュリティ
- API キーはサーバー側だけで利用し、静的 HTML には出力しません。
- 外部 API の共通ヘッダーでは、
Authorization、Cookie、API キー、トークン類に見える値を保存・出力しないようにしています。 - 静的出力ジョブは WordPress の home URL と同一オリジンだけを取得します。
- 管理機能と API キー発行は
manage_options権限を持つユーザーに限定されています。 - Lighthouse/AI 分析でテーマファイルを送信する可能性があるため、実運用では送信内容を理解したうえで利用してください。
- このリポジトリには実 API キー、SFTP 情報、秘密鍵、サーバー固有の認証情報を含めないでください。
注意事項
- 自動再生成は標準では行いません。管理画面または WP-CLI から手動で生成します。
- フォーム、検索、コメントなどの動的機能は、静的 HTML 内では外部 API への置換が必要です。
DISABLE_WP_CRONが有効な環境では、サーバー cron でwp-cron.phpを実行してください。- サーバー、PHP-FPM、プロキシ、ブラウザ、Gemini API 側のタイムアウトや上限はプラグイン側で完全には制御できません。
English
Overview
Static HTML AI Exporter is a WordPress plugin for exporting public WordPress pages as static HTML and serving them from the same public URLs. It also includes WebP image optimization, Gemini-powered HTML infographic generation, knowledge graph registration, an external knowledge API, and an admin assistant.
Features
- Export public WordPress URLs as static HTML
- Serve generated HTML from normal WordPress-style URLs
- Generate static HTML for a single post or page
- Convert JPEG/PNG images to WebP cache files
- Rewrite
src,srcset,poster, and CSSurl(...)references to WebP paths during export - Generate HTML/CSS infographics with the Gemini API
- Insert SEO-visible infographics without iframes
- Preview and insert infographics in the block editor
- Generate infographics from Markdown files
- Split post content into summarized knowledge chunks
- Manage knowledge graph nodes and edges
- Provide an external knowledge API with API key management
- Provide an admin assistant that can use registered knowledge
- Support WP-CLI inventory and export commands
Requirements
- WordPress 6.2 or later
- PHP 7.4 or later
- A writable server directory for static HTML output
- GD or Imagick with WebP support for image conversion
- Google Gemini API key for Gemini features
- OpenAI API key for knowledge embedding features
- PostgreSQL + pgvector for optional vector search
Installation
- Upload the
static-html-aidirectory towp-content/plugins/. - Activate the plugin in the WordPress admin.
- Open
Tools > Static HTML AI. - Configure the output path, public base URL, API keys, and model settings.
- Start an export from the admin screen or run it with WP-CLI.
Gemini and OpenAI API keys can be configured with wp-config.php constants instead of saving them in the admin screen.
define( 'STATIC_HTML_AI_GEMINI_API_KEY', 'your-gemini-api-key' );
define( 'STATIC_HTML_AI_OPENAI_API_KEY', 'your-openai-api-key' );
Do not commit real API keys to a public repository.
Static HTML Export
The plugin can export the home page, posts, pages, categories, tags, archives, pagination pages, and sitemaps. Exported files are created under releases/{job_id} and published to current after a successful job.
Single-page export is available from the post/page edit screen.
Normal URL Delivery
Generated static HTML can be served from normal URLs such as /service/example/. The plugin supports .htaccess delivery, plugin fallback delivery, and direct real-URL placement for hosting environments where rewrite rules are limited.
WebP Optimization
Images can be converted per page from the edit screen or in bulk from the plugin settings screen. Original images and post content are not modified. During static export, only successfully converted images are rewritten to WebP paths.
If conversion fails, the original image path is kept to avoid broken links.
Infographic Generation
The plugin can generate HTML/CSS infographics from post or page content using Gemini. Generated infographics are inserted as normal HTML, not iframes, so search engines can read them.
The infographic CSS is scoped under a dedicated parent class and protected with partial reset CSS. Unsafe elements such as scripts, external assets, and event attributes are removed before saving.
Knowledge Registration
From the post edit screen, articles can be split by headings, summarized, and registered as knowledge chunks. The knowledge admin screen lets you manage memos, keywords, and relationships.
Knowledge groups are designed to sync with WordPress post categories. API keys can target a specific group or all groups.
Knowledge API
API keys can be issued from the Knowledge API admin screen. External systems can search registered knowledge or add new knowledge.
API keys are shown only once immediately after creation. Create a new key if one is lost.
Authentication header:
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Automata-compatible API:
POST /wp-json/static-html-ai/v1/external/knowledge/search
POST /wp-json/static-html-ai/v1/external/knowledge/fragments
Legacy action-based API:
POST /wp-json/static-html-ai/v1/knowledge-external
WP-CLI
wp static-html-ai inventory
wp static-html-ai export --target=/absolute/path/to/static-root
wp static-html-ai infographic regenerate --post_type=post
Security
- API keys are used server-side and are not written into generated static HTML.
- Dynamic adapter headers that look like
Authorization,Cookie, API keys, or tokens are blocked from being saved or exported. - Export jobs only fetch URLs from the same origin as the WordPress home URL.
- Admin features and API key management require
manage_options. - Lighthouse/AI analysis may send theme file contents to an AI provider. Review what is sent before using it in production.
- Do not include real API keys, SFTP credentials, private keys, or server-specific credentials in this repository.
Notes
- Automatic regeneration is not enabled by default. Exports are started manually from the admin screen or WP-CLI.
- Dynamic features such as forms, search, and comments need external API replacements in generated static HTML.
- If
DISABLE_WP_CRONis enabled, configure a server cron to runwp-cron.php. - Server, PHP-FPM, proxy, browser, and external API timeouts may still apply.