TechDocs Best Practices
Learn best practices for creating and maintaining documentation with TechDocs, including diagrams, videos, and advanced features.
TechDocs leverages MkDocs to convert Markdown files into static documentation sites, following the docs-like-code philosophy. This guide covers best practices for creating effective documentation, including site structure, diagrams, videos, and advanced features.
Documentation site structure
Single-page documentation
Single-page documentation is ideal for quick-start guides, FAQs, or standalone documentation that does not require complex navigation.
When to use:
Simple project documentation
Quick reference guides
FAQ pages
Getting started tutorials
Setup:
Create a
docsfolder in your repositoryAdd a single
README.mdorindex.mdfile with your contentRegister the repository in your
catalog-info.yamlwith the TechDocs annotation
TechDocs will automatically render the content without additional configuration.
Multi-page documentation
For comprehensive documentation requiring hierarchical navigation and better content organization, use multi-page sites.
Option 1: Auto-generated navigation
MkDocs automatically generates navigation based on your folder and file structure, no configuration required.
Example directory structure:
Resulting navigation:
Home
Guide
Getting Started
Troubleshooting
Reference
API
Optional mkdocs.yml configuration:
Option 2: Custom navigation
For precise control over navigation structure and ordering, define a nav section in your mkdocs.yml file.
Example mkdocs.yml with custom navigation:
Video tutorial:
Add diagrams and images
Visual elements like diagrams and images enhance documentation clarity and understanding.
Static images (PNG, JPG, SVG)
Directory structure:
Store images in the docs folder or a subdirectory (commonly docs/static):
Reference in Markdown:
Note:
Avoid using image reference-style links (e.g.,
[![Image]][ref]). These are primarily meant for linking images and may not be consistently handled, leading to broken rendering or unexpected link behavior.
Path guidelines:
If image is at
/docs/static/architecture-diagram.png, use:static/architecture-diagram.pngIf image is at
/docs/architecture-diagram.png, use:architecture-diagram.pngAlways use relative paths from the Markdown file's location
Diagrams as code
Create diagrams directly in Markdown using diagram-as-code tools. TechDocs supports multiple diagram formats through the techdocs-core plugin.
Mermaid diagrams
Mermaid is supported out of the box and ideal for flowcharts, sequence diagrams, Gantt charts, and more.
Supported diagram types:
Flowcharts
Sequence Diagrams
Gantt Charts
Pie Charts
For more syntax options, refer to the Mermaid documentation.
Instructions to use in local environment:
Ensure the
mkdocs-mermaid2-pluginis installed and configured in yourmkdocs.yml.
For more information refer here
PlantUML for advanced diagrams
PlantUML is ideal for more detailed and customizable diagrams, such as class diagrams, activity diagrams, and deployment diagrams.
Example usage:
In your Markdown file:
Instructions to use in local environment:
PlantUML is available as part of the
techdocs-coreplugin.
For more information refer here
Graphviz diagrams
Allows inline rendering of Graphviz diagrams (DOT language) directly in Markdown files.
Example Usage
Instructions to use in local environment:
Graphviz is available as part of the
techdocs-coreplugin.
For more information refer here
Embed videos in TechDocs
Embedding videos enriches documentation, especially for tutorials or product demonstrations.
Embed videos using iframe
To embed videos hosted on platforms like YouTube or Vimeo, use the following syntax:
Replace
VIDEO_IDwith the unique ID of the video from the platform (e.g., dQw4w9WgXcQ for YouTube).Adjust width and height for desired sizing.
Allowed domains:
To maintain security and compatibility, only embed videos from the following domains are allowed:
youtube.com
www.youtube.com
youtu.be
www.youtu.be
drive.google.com
zoom.us
loom.com
sharepoint.com
dropbox.com
docs.google.com
Note:
Iframe-based videos cannot be rendered locally when using tools like techdocs-cli to preview documentation. They will render correctly only when the TechDocs site is hosted and accessed through the Internal Developer Portal (IDP).
Embed self-hosted videos
For videos hosted in your repository or accessible via a direct URL, use the Markdown <video> tag:
Use this method for
.mp4or other self-hosted video formats stored in the repository.
Create download links for static assets
You may want to make files available for download by your users such as PDF documents, images, or code templates. Download links for files included in your docs directory can be made by adding {: download } after a Markdown link.
The user's browser will download the file as download.jpg when the link is clicked.
Specify a file name to control the name the file will be given when it is downloaded:
Last updated
Was this helpful?