Docs as code: how to run documentation like software
Docs as code means writing docs in plain text, keeping them in Git, reviewing them in pull requests and testing them in CI. A setup you can copy today.

Docs as code is the practice of treating documentation the way you treat source code: you write it in a plain text format such as Markdown, store it in Git next to the code it describes, change it through pull requests with review, and let automated checks catch broken links and formatting before anything is published. The result is documentation that changes in the same commit as the feature, so it stays accurate.
Write the Docs, the documentation community, describes it as "a philosophy" that "you should be writing documentation with the same tools as code," and lists the tools: issue trackers, version control, plain text markup, code reviews and automated tests (Docs as Code, checked November 2026). Below is what that looks like in a real repository.
What does a docs as code setup look like?
A docs as code setup is a folder of Markdown files inside the repository, a configuration file for whatever builds the site, and a CI job that checks the files on every pull request. Nothing about it needs a special platform.
A layout that works for most projects:
my-project/
docs/
index.md
getting-started.md
guides/
install.md
configuration.md
reference/
cli.md
api.md
images/
dashboard.png
.markdownlint.jsonc
mkdocs.yml (or docusaurus.config.js, hugo.toml, conf.py)
.github/
workflows/
docs.yml
CODEOWNERS
README.md
The README.md stays short and links into docs/. Everything a user reads after the first screen lives in the docs folder, where it can be organized, built and checked.
Why keep documentation in the same repository as the code?
Keeping docs in the code repository means one pull request can change the behavior and the description of that behavior together. Reviewers see both, and the docs can never lag behind a release by more than one merge.
| Question | Docs in a separate wiki or CMS | Docs as code |
|---|---|---|
| Who can change it? | Anyone with an account | Anyone, through a reviewed pull request |
| When does it update? | When someone remembers | In the same change as the code |
| Can you see the history? | Page history, if the tool keeps it | Full Git history and blame |
| Can you roll back? | Sometimes | git revert |
| Can you test it? | Rarely | Link checks, linting, build checks in CI |
| Does it match a release? | Shows the latest only | Tag the docs with the release |
The trade-off is that non-developers have to learn a little Git, or use the web editor on GitHub or GitLab. For teams where most writers never touch the code, a wiki may still be the better home for internal notes, while user-facing docs move into the repository.
Which format should you write in?
Write in Markdown unless you have a reason not to. It is the format GitHub, GitLab and nearly every docs generator read by default, and most developers already know it. reStructuredText and AsciiDoc are the other two common choices; both have richer built-in features for cross-references and includes, at the cost of a steeper syntax.
A few conventions keep a docs folder consistent:
- One
#heading per page, then##and###in order. Generators build the sidebar and page outline from these, so skipping levels shows up as a broken menu. See Markdown headings. - Language tags on every code block, so commands and config files get highlighting and can be checked.
- Relative links between pages, such as
[configuration](../guides/configuration.md), so links work on GitHub, in clones and in the built site. - Front matter only where the generator needs it, for a page title or sidebar position.
- Lowercase, hyphenated file names, because they become URLs.
How do you review documentation in pull requests?
Review docs changes the same way you review code: in the pull request diff, with a named owner who has to approve. Plain text makes this practical, because a one-word change shows up as a one-word diff instead of a binary file.
Two GitHub features make it routine:
-
CODEOWNERS. A line in
.github/CODEOWNERSrequests review from the docs owners whenever a file underdocs/changes./docs/ @your-org/docs-team -
Suggested changes. Reviewers can propose an exact rewrite of a line in a review comment, and the author applies it with one click. The syntax is a fenced block with the language
suggestion.
A short checklist for docs reviewers:
- Every command in the change was run, and the output shown matches
- New pages are linked from the sidebar or an index page
- Screenshots match the current interface
- Renamed headings did not break links elsewhere
What should CI check in your docs?
CI should fail the pull request on problems a reviewer will miss by eye: broken links, malformed Markdown and a site that no longer builds. Spelling and style checks are useful but noisier, so many teams run them as warnings first.
| Check | What it catches | Common tools |
|---|---|---|
| Markdown lint | Skipped heading levels, missing code languages, stray HTML | markdownlint-cli2, remark-lint |
| Link check | Dead external links, wrong relative paths | lychee, markdown-link-check |
| Prose lint | Banned terms, passive voice, product name spelling | Vale |
| Build | Missing pages in the nav, broken includes | Your generator's build command |
A minimal GitHub Actions workflow that lints and builds an MkDocs site:
name: docs
on:
pull_request:
paths:
- "docs/**"
- "mkdocs.yml"
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- run: npx markdownlint-cli2 "docs/**/*.md"
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- run: pip install mkdocs
- run: mkdocs build --strict
The paths filter means the job only runs when docs change, and --strict makes MkDocs treat warnings, such as a link to a missing page, as failures. Rule IDs and configuration for the lint step are in Markdown linting.
Which tools build the site?
Any static site generator that reads Markdown will do. Pick by the language your team already uses, since you will need to install and occasionally debug it.
- MkDocs (Python): one
mkdocs.yml, adocs/folder andmkdocs servefor a local preview. Popular for project docs with the Material theme. - Docusaurus (JavaScript): docs, a blog and versioned docs per release, with MDX for interactive components.
- Sphinx (Python): the long-standing choice for Python projects; reads Markdown through the MyST parser as well as reStructuredText.
- Hugo (Go binary): very fast builds and no runtime dependencies.
Publishing a folder of Markdown as a site, with commands for Hugo, Jekyll and Astro, is covered in how to turn Markdown into a website.
How do you start without a big migration?
Start with one page. Move the most-read wiki page into docs/, link it from the README and add the lint step to CI. Once one page has gone through a reviewed pull request, the rest of the process is repetition.
- Create
docs/and move one page into it as Markdown. - Add a
CODEOWNERSline fordocs/. - Add markdownlint and a link checker to CI.
- Pick a generator only when you have more pages than a README can link to.
- Add a line to your pull request template: "Docs updated, or not needed because…"
The last step does the most. It makes "did you update the docs?" a question every author answers, instead of one a reviewer has to remember to ask.
Writing docs as code in Noteline
Noteline, which we make, opens a repository's docs/ folder as it is (Cmd+O on a Mac, Ctrl+O on Windows and Linux), edits the Markdown files in place and leaves Git to you. Headings, tables and fenced code blocks are formatted as you type, with syntax highlighting inside code blocks, and Find in Folder (Cmd+Shift+F or Ctrl+Shift+F) searches every page at once. The sidebar lists Markdown, text and PDF files only, and hidden folders such as .github are skipped, so edit mkdocs.yml and workflow files in your code editor. More on writing documentation is on the documentation page.