How to Publish Docs as Code With TechDocs
TechDocs builds a service Markdown docs from an mkdocs.yml and shows them in the portal next to the service.
Add an mkdocs.yml and a docs/ folder, annotate the catalog entity with backstage.io/techdocs-ref, and build docs in CI. Documentation lives with the code and surfaces in the portal.
Steps
- Add
mkdocs.ymlanddocs/index.mdto the repo. - Add the
backstage.io/techdocs-ref: dir:.annotation tocatalog-info.yaml. - Build and publish docs in CI (or let the portal build them).
- Verify the Docs tab appears on the entity page.
mkdocs config
mkdocs.yml
site_name: payments-api
nav:
- Home: index.md
- Runbook: runbook.md
plugins:
- techdocs-coreCI publish
.github/workflows/techdocs.yml
- run: pip install mkdocs-techdocs-core
- run: npx @techdocs/cli generate --no-docker
- run: npx @techdocs/cli publish --publisher-type awsS3 --entity default/component/payments-apiGotchas
- The
techdocs-refannotation must match where the docs live (dir:.for in-repo). - Use the
techdocs-coreplugin; a plain mkdocs build will miss the required rendering.
Related guides
How to Register a Service in the Backstage CatalogAdd a catalog-info.yaml so a service appears in the Backstage software catalog with its owner, lifecycle, and…
How to Set Up Service Health ScorecardsMeasure service health with scorecards that check for a required CI workflow, an owner, and TechDocs, nudging…