<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Diego A. Carrasco Gubernatis | Personal Website (Posts about python)</title><link>https://diegocarrasco.com/</link><description></description><atom:link href="https://diegocarrasco.com/categories/python.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2026 &lt;a href="mailto:hi@diegocarrasco.com"&gt;Diego Carrasco G.&lt;/a&gt; </copyright><lastBuildDate>Sat, 11 Apr 2026 08:03:46 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>FlexSearch Plugin for Nikola: New Version 0.2 Released</title><link>https://diegocarrasco.com/flexsearch-plugin-for-nikola-new-version-02-released/</link><dc:creator>Diego Carrasco G.</dc:creator><description>&lt;figure&gt;&lt;img src="https://diegocarrasco.com/images/social-images/flexsearch-plugin-for-nikola-new-version-02-released.jpg"&gt;&lt;/figure&gt; &lt;h2 id="tldr"&gt;TLDR&lt;/h2&gt;
&lt;p&gt;Version 0.2 of the &lt;a href="https://diegocarrasco.com/introducing-the-flexsearch-plugin-for-nikola"&gt;FlexSearch Plugin for Nikola&lt;/a&gt; is now available! This update adds page indexing, improved search relevance, better UI, and more configuration options. You can now search both posts and pages, with results showing content type badges and better formatting.&lt;/p&gt;
&lt;h2 id="whats-new-in-version-02"&gt;What's New in Version 0.2?&lt;/h2&gt;
&lt;p&gt;It's been a while since I &lt;a href="https://diegocarrasco.com/introducing-the-flexsearch-plugin-for-nikola"&gt;first released&lt;/a&gt; the FlexSearch plugin, and I've been using it a lot and working on improvements (I developed the plugin because I use this site as a personal repository). &lt;/p&gt;
&lt;p&gt;Version 0.2 brings several new features and improvements (IMHO) that make the search functionality more powerful and flexible.&lt;/p&gt;
&lt;h3 id="major-new-features"&gt;Major New Features&lt;/h3&gt;
&lt;h4 id="1-page-indexing"&gt;1. Page Indexing&lt;/h4&gt;
&lt;p&gt;The original version only indexed posts (and I did not care until I wanted to find a page and couldn't find it), but now you can also index pages! This means you can search through all your content, not just blog posts. This is particularly useful for me as I published a lot of &lt;a href="https://diegocarrasco.com/the-digital-marketers-playbook-additional-resources"&gt;additional resources&lt;/a&gt; for my book &lt;a href="https://dmplaybook.cc/"&gt;"The Digital Marketer's Playbook,"&lt;/a&gt; and they could not be found using the search. It took me a while but it now works 😁&lt;/p&gt;
&lt;p&gt;You can control this with 3 new configuration options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;FLEXSEARCH_INDEX_POSTS&lt;/code&gt; (default: &lt;code&gt;True&lt;/code&gt;) - Whether to index posts&lt;/li&gt;
&lt;li&gt;&lt;code&gt;FLEXSEARCH_INDEX_PAGES&lt;/code&gt; (default: &lt;code&gt;False&lt;/code&gt;) - Whether to index pages&lt;/li&gt;
&lt;li&gt;&lt;code&gt;FLEXSEARCH_INDEX_DRAFTS&lt;/code&gt; (default: &lt;code&gt;False&lt;/code&gt;) - Whether to index draft content&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="2-improve-the-search-index"&gt;2. Improve the search index&lt;/h4&gt;
&lt;p&gt;The search index now includes titles, content, and tags (which you can change in the source code), making search results much more relevant. The plugin uses a multi-field search approach that combines all these elements when searching:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="nx"&gt;searchIndex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;tags&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;data[key].content&lt;/code&gt; part is commented out by default as I was getting just too many results.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This means that searching for a tag will find all posts with that tag, and searching for words in titles will give those results higher priority.&lt;/strong&gt; This is thanks to the &lt;code&gt;flexsearch&lt;/code&gt; library.&lt;/p&gt;
&lt;h4 id="3-content-type-display"&gt;3. Content Type Display&lt;/h4&gt;
&lt;p&gt;Search results now show whether an item is a post or a page, with styled badges. This makes it easier to distinguish between different types of content in your search results. (this is at least important for me)&lt;/p&gt;
&lt;p&gt;Just search something on this sile, for example &lt;code&gt;nikola&lt;/code&gt; to see how it behaves.&lt;/p&gt;
&lt;h4 id="4-keyboard-shortcuts"&gt;4. Keyboard Shortcuts&lt;/h4&gt;
&lt;p&gt;I've added some convenient keyboard shortcuts. I don't really remember why I did not add this before:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Press &lt;code&gt;ESC&lt;/code&gt; to close the search overlay&lt;/li&gt;
&lt;li&gt;Press &lt;code&gt;Enter&lt;/code&gt; to submit your search&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="5-better-url-handling"&gt;5. Better URL Handling&lt;/h4&gt;
&lt;p&gt;The plugin now uses absolute paths (&lt;code&gt;/search_index.json&lt;/code&gt;) instead of relative ones, which fixes an issue with path resolution on different pages. It also adds &lt;code&gt;?utm_source=internal_search&lt;/code&gt; to result URLs, making it easier to track internal search usage in analytics, if you use any.&lt;/p&gt;
&lt;h3 id="technical-improvements"&gt;Technical Improvements&lt;/h3&gt;
&lt;p&gt;For those who like to tinker with their plugins, I've also made some technical improvements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Added console logging for easier debugging&lt;/li&gt;
&lt;li&gt;Updated to the latest FlexSearch v0.8.0 library, released 4 days ago by pure coincidence&lt;/li&gt;
&lt;li&gt;Added better error handling throughout the code&lt;/li&gt;
&lt;li&gt;Improved code organization and structure (or at least I hope so)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="how-to-update"&gt;How to Update&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;IMPORTANT&lt;/strong&gt;: Remember to update the javascript snippets with the new versions. Make sure you read the &lt;a href="https://github.com/getnikola/plugins/tree/master/v8/flexsearch_plugin"&gt;README&lt;/a&gt; and &lt;strong&gt;make a backup of your plugin version before updating&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If you're already using or if you want to install the FlexSearch plugin, you can use:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;nikola&lt;span class="w"&gt; &lt;/span&gt;plugin&lt;span class="w"&gt; &lt;/span&gt;-i&lt;span class="w"&gt; &lt;/span&gt;flexsearch_plugin
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;After updating, rebuild your site with &lt;code&gt;nikola build -a&lt;/code&gt; to generate the updated search index.&lt;/p&gt;
&lt;h2 id="configuration"&gt;Configuration&lt;/h2&gt;
&lt;p&gt;To enable page indexing, add these lines to your &lt;code&gt;conf.py&lt;/code&gt;:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="c1"&gt;# FlexSearch Plugin Configuration&lt;/span&gt;
&lt;span class="n"&gt;FLEXSEARCH_INDEX_POSTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;  &lt;span class="c1"&gt;# Default is True&lt;/span&gt;
&lt;span class="n"&gt;FLEXSEARCH_INDEX_PAGES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;  &lt;span class="c1"&gt;# Default is False&lt;/span&gt;
&lt;span class="n"&gt;FLEXSEARCH_INDEX_DRAFTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;  &lt;span class="c1"&gt;# Default is False&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id="whats-next"&gt;What's Next?&lt;/h2&gt;
&lt;p&gt;As I'm using the plugin myself, and I don't plan to migrate my site from Nikola anytime soon, I will at least keep maintaining the plugin to meet my needs.&lt;/p&gt;
&lt;p&gt;That may include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Better mobile support, although the snippets and css are already responsive and work for me)&lt;/li&gt;
&lt;li&gt;More customization options for search results (maybe some filters)&lt;/li&gt;
&lt;li&gt;Anything I find useful while I use this.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you have suggestions or encounter any issues, feel free to open an issue with a pull request on the &lt;a href="https://github.com/getnikola/plugins"&gt;Nikola Plugins repository&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://diegocarrasco.com/introducing-the-flexsearch-plugin-for-nikola"&gt;FlexSearch Plugin for Nikola (Initial Release)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://getnikola.com/"&gt;Nikola Static Site Generator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nextapps-de/flexsearch"&gt;FlexSearch Library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://plugins.getnikola.com/v8/flexsearch_plugin/"&gt;FlexSearch Plugin Repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><category>flexsearch</category><category>full-text search</category><category>nikola</category><category>nikola plugin</category><category>nikola ssg</category><category>open source</category><category>plugin updates</category><category>project</category><category>python</category><guid>flexsearch-plugin-for-nikola-new-version-02-released</guid><pubDate>Sat, 22 Mar 2025 08:00:00 GMT</pubDate></item></channel></rss>