Add Kapa AI search

Three ways to add Kapa AI search to your Material for MkDocs site.
Published

May 31, 2025

Modified

August 23, 2025

These guides are deprecated. I’m no longer updating them. This is due to developments in the MkDocs ecosystem: the maintainer of MkDocs is taking it in a new direction, and the creator of the Material theme is building his own static site generator, Zensical.

Learn more:

The Slow Collapse of MkDocs
Zensical

This page provides some quick guidance on adding Kapa to your Material for MkDocs documentation site.

NoteTheme customisation knowledge

This guide assumes some familiarity with customizing MkDocs themes. If you’ve never added custom CSS and JavaScript, and have never worked with template overrides before, read Material’s Customization guide first.

Kapa: what and why

Kapa provides a RAG chatbot. From their site:

Kapa.ai turns your technical content into a production-ready Al assistant you can deploy on your documentation in days.

You add a chatbot to your site that’s focused on your content. The answers use the sources that you’ve chosen to connect. This makes them more likely to be accurate and up to date compared to a generic AI.

Kapa can pull in a wide range of data sources in addition to your documentation site, and you can add the chatbot to places like your company Slack or Discord, not just your docs. It also provides some very useful analytics and feedback from users, which can help identify documentation gaps (this is one of my favourite features). You can review user questions, see which ones it struggled to answer, and where you can improve your docs. Kapa is constantly adding new features, so check out their website for full details.

At the moment (May 31, 2025), Kapa does the initial setup for all users, and doesn’t have a completely self-serve option. They generously gave me a free trial to play around with it. I’m hoping they’ll eventually offer self-serve, as it felt fairly straightforward to set up myself.

Adding Kapa as a simple widget

By default, Kapa provides a widget in the bottom right of your site. If you want to use this, then you can work through the Kapa docs.

  1. Connect Data Sources: connect your documentation site, and any other sources.
  2. Add AI to MkDocs: follow Kapa’s own guide to add the widget.
  3. Explore the Configuration options to customize the widget.

Add a separate Kapa button

This is the approach I took in n8n’s documentation.

“Screenshot showing a green button added to the top bar of a Material for MkDocs site”

See it in action on n8n’s docs site.

For specific details of the n8n implementation, explore n8n’s docs repository. The kapaButton partial contains the button HTML and display logic.

Steps:

  1. Connect Data Sources: connect your documentation site, and any other sources.
  2. Add AI to MkDocs: follow Kapa’s own guide to add the widget.
  3. Having added the widget, hide it by setting script.setAttribute("data-button-hide", true); in init_kapa_widget.js.
  4. Create a partial for your button. Although this isn’t overriding an existing partial, you can still put it in your overrides directory. If you’re not familiar with overrides and theme extension in Material for MkDocs, refer to Customization | Extending the theme.
  5. Include the partial wherever you want to display it. For example, to put it next to the search box:
    1. In the overrides directory, create partials/header.html.
    2. Copy in the theme’s header partial. MkDocs now uses this header partial, rather than the one from the theme.
    3. Include your Kapa button partial beside the search element: html title="header.html" hl_lines="2" <!-- other header elements --> {% include "partials/kapaButton.html" %} <!-- Button to open search modal --> {% if "material/search" in config.plugins %} ...