A knowledge base can replace single templates of its theme and add its own files to the website. The theme stays as it is, so it keeps receiving the updates of new KB4IT versions.
Replace a template
- Create the folder
overrides/templates/next toconfig/andsource/. -
Copy the template you want to change from the theme into it, keeping its name. The bundled themes are in the KB4IT package; this prints the folder of techdoc:
python3 -c "import kb4it, os; print(os.path.join(os.path.dirname(kb4it.__file__), 'resources', 'themes', 'techdoc', 'templates'))" -
Edit the copy and build. The build log shows
TEMPLATE_OVERRIDE name=<template>, and every page is rebuilt.
KB4IT looks for a template in this order and uses the first it finds:
overrides/templates/of the knowledge base.- The
templates/folder of the theme. - The common templates of KB4IT.
Delete the copy to go back to the theme's template.
Warning
A template you copied does not change when the theme does. After upgrading KB4IT, compare your copy with the theme's new version.
Add your own files
Everything in overrides/static/ is copied, as it is, into the website root. Put stylesheets, scripts or images there, for example overrides/static/css/site.css, and link them from an overridden template.
Use another folder than overrides with "overrides": "my-folder" in repo.json.
Example: a browser library of your own
Mermaid diagrams and KaTeX formulas are built in; see diagrams. For another browser library, such as a chart or a map:
- Put the library file in
overrides/static/js/. -
Copy techdoc's
HTML_FOOTER.tplintooverrides/templates/and add the script lines just before its</body>line (anything after</html>is dropped):<script src="js/library.min.js"></script> <script>startLibrary();</script> -
Write what the library needs in a document as an HTML block. Markdown keeps HTML blocks as they are.
Linked from