Add AI to MkDocs
Integrate the Kapa chat widget into your MkDocs documentation to enable users to ask natural language questions about your product, significantly enhancing user experience by providing quick and accurate answers.
Prerequisites
Before adding the widget to your MkDocs site, you'll need to:
- Ensure you have a Kapa project set up with your knowledge sources added
- Follow the general installation instructions to enabled your domain and obtain your
Website ID
Installation
-
Locate your
mkdocs.yml
configuration file and add the following to theextra_javascript
section: -
Add the following code to the
extra_javascript
section of themkdocs.yml
file:
extra_javascript:
- "javascript/init_kapa_widget.js"
-
Create a new JavaScript file named
init_kapa_widget.js
in thedocs/javascript
folder. -
Add the following code to the
init_kapa_widget.js
file, replacing the placeholders with your specific project parameters:
document.addEventListener("DOMContentLoaded", function () {
var script = document.createElement("script");
script.src = "https://widget.kapa.ai/kapa-widget.bundle.js";
script.setAttribute("data-website-id", "XXX-XXX-XXX");
script.setAttribute("data-project-name", "PROJECT_NAME");
script.setAttribute("data-project-color", "#HEX_COLOR_CODE");
script.setAttribute("data-project-logo", "https://LINK_TO_LOGO.com/logo.png");
script.async = true;
document.head.appendChild(script);
});
- Save the changes to both files and rebuild your MKDocs project. The Kapa website widget should now be installed and visible on your documentation pages.
To tailor the widget to your brand and specific needs, visit our Configuration page. There, you'll find detailed instructions on how to adjust colors, logos, and other widget properties.