Built-in Variables Reference

Built-in Variables Reference

docmd automatically registers a rich set of built-in variables during every build. These variables require zero configuration and can be used immediately in markdown content, template banners, footer copyright strings, and meta tags.

System & Build Variables

Variable Alias Example Value Description
docmd.version DOCMD_VERSION 0.9.9 The current docmd compiler version running the build.
docmd.buildYear BUILD_YEAR 2026 The 4-digit calendar year when the documentation was built.
docmd.buildDate BUILD_DATE 2026-10-31 The ISO calendar date (YYYY-MM-DD) of the build.
docmd.buildTime BUILD_TIME 2026-10-31T10:50:00Z The full ISO 8601 UTC timestamp of the build.
Live System Variables

These variables are rendered live in this documentation build:

  • Compiler Version: v0.10.1
  • Calendar Build Year: 2026
  • Build Timestamp: 2026-11-16T18:04:03.902Z

In your docmd.config.json, use {{ docmd.buildYear }} to ensure your copyright year stays up to date on every deployment automatically:

{
  "footer": {
    "copyright": "Copyright © {{ docmd.buildYear }} Acme Technologies, Inc. All rights reserved."
  }
}

Git & Repository Metadata

When running inside a Git repository, docmd inspects repository metadata to provide version control variables:

Variable Alias Example Value Description
docmd.gitCommit git.commit, GIT_COMMIT 7a9b1c2 The 7-character short SHA of the current Git commit.
docmd.gitBranch git.branch, GIT_BRANCH main The current active Git branch name.

Displaying Commit Information in Markdown

Use escaped variable syntax in markdown to reference repository commit details:

> This documentation was generated from commit `{{ docmd.gitCommit }}` on branch `{{ docmd.gitBranch }}` on {{ docmd.buildDate }}.
Live Git Metadata

This documentation page was compiled from commit f8f75b6 on branch main at 2026-11-16.

Site & Page Context Variables

docmd exposes contextual variables representing the project configuration and the currently rendered document:

Variable Example Value Description
site.title docmd docs The site title configured in docmd.config.json.
site.base / The configured base URL path.
page.title Built-in Variables Reference The title of the current page (from frontmatter or # First Heading).
page.slug variables/built-in-variables The relative URL path or slug of the current page without file extensions.
page.path variables/built-in-variables.md The relative source markdown file path of the page.

Dynamic Page Header Context

# Welcome to {{ site.title }}

You are currently viewing **{{ page.title }}** (`{{ page.slug }}`).
Current Page Context
  • Page Title: Built-in Variables Reference
  • Page Slug: variables/built-in-variables
  • Page File Path: /09/variables/built-in-variables/
  • Site Title: docmd docs
  • Site Base: /
Configuration Field Interpolation

All built-in variables are also available across configuration fields like layout.banners.top.content and footer.copyright. They resolve during the pre-rendering compilation pass.