{"id":18733926,"date":"2025-11-26T23:14:02","date_gmt":"2025-11-26T23:14:02","guid":{"rendered":"https:\/\/wordpress.org\/support\/?post_type=topic&#038;p=18733926"},"modified":"2026-04-08T19:09:18","modified_gmt":"2026-04-08T19:09:18","slug":"typesense-for-static-wordpress","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/typesense-for-static-wordpress\/","title":{"rendered":"Typesense for Static WordPress"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This plugin is a gem of a gift to the WordPress community. Embedding a modern and performant search interface into your website couldn&#8217;t possibly be easier.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The plugin uses the Algolia open-source vanilla JS libraries &#8220;InstantSearch.js&#8221; and &#8220;Autocomplete.js&#8221;, which communicate with your Typesense server using fetch requests in the browser; no connection to WordPress needed, and thus fully compatible with static generation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Via their WP-Admin GUI, the software indexes your WP posts and pages as Typesense &#8220;documents&#8221; and &#8220;collections&#8221;; while the frontend search interface <code>fetch<\/code>es data direct from your Typesense instance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I used the Typesense provided Docker image to spin up a self-hosted instance; added my instance API keys to the Typesense plugin settings in WP-Admin; indexed 4000+ posts in a couple minutes; added the default shortcode to a test page; ran a SimplyStatic export, and voil\u00e0, it works splendidly!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Important note for static site generation:<\/strong> Prior to running an index, you&#8217;ll need to filter the permalink; otherwise the search results will link to your WP:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**<br \/> * Filter Typesense document data before it is indexed.<br \/>**\/<br \/><br \/>add_filter( 'cm_typesense_data_before_entry', function( $formatted_data, $raw_data, $object_id ) {<br \/>    if ( isset( $formatted_data&#091;'permalink'] ) ) {<br \/>        $formatted_data&#091;'permalink'] = str_replace(<br \/>            'wp&#091;dot]example&#091;dot]com',<br \/>            'example&#091;dot]com',<br \/>            $formatted_data&#091;'permalink']<br \/>        );<br \/>    }<br \/><br \/>    return $formatted_data;<br \/>}, 10, 3 );<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>*<\/strong>WordPress[dot]org doesn&#8217;t permit URLs in reviews, hence why the <code>[dot]<\/code> chicanery in the above snippet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Pax et bonum.<\/p>\n","protected":false},"template":"","class_list":["post-18733926","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18733926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18733926\/revisions"}],"predecessor-version":[{"id":18733949,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18733926\/revisions\/18733949"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=18733926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}