Skip to content

Complete mkdocs-git-revision-date-localized-plugin Error Resolution Guide

Target Audience

  • Intermediate users facing git-revision-date plugin errors in MkDocs operations

Key Points

  1. Instant resolution of plugin configuration errors
  2. Proper adjustment of datetime display formats
  3. Root cause resolution of git history issues

Why This Problem is Critical Now

The mkdocs-git-revision-date-localized-plugin is essential for automatic article timestamp management, but frequently causes build errors due to configuration mistakes and git environment differences. Particularly in CI/CD environments, shallow clone-related history insufficiency cases are rapidly increasing.

Solution Steps Overview

StepContentSuccess Metric
1Plugin configuration normalizationBuild errors resolved
2Proper git history retrievalAccurate datetime display
3Timezone and locale configurationDisplay in expected format

Step 1: Plugin Configuration Normalization

Fix the most frequent configuration errors.

# mkdocs.yml
plugins:
  - git-revision-date-localized:
      enable_creation_date: true
      type: timeago
      timezone: Asia/Tokyo
      locale: en
      fallback_to_build_date: true
      enabled: !ENV [ENABLE_GIT_REVISION, true]

Important: fallback_to_build_date: true ensures fallback for insufficient git history, enabled: !ENV allows conditional disabling in CI environments.

Step 2: Proper Git History Retrieval

Resolve history insufficiency caused by shallow clone in CI/CD.

# .github/workflows/deploy.yml (example)
- uses: actions/checkout@v4
  with:
    fetch-depth: 0  # Full history retrieval

- name: Check git history
  run: |
    git log --oneline -5
    git config --global --add safe.directory /github/workspace

Diagnostic Command: Run git log --oneline docs/your-file.md locally to check file history.

Step 3: Timezone and Locale Configuration

Properly adjust datetime display format.

plugins:
  - git-revision-date-localized:
      type: date          # 2025-09-01
      # type: datetime    # 2025-09-01 10:30:00
      # type: timeago     # 2 days ago
      timezone: UTC
      locale: en

Common Pitfalls and Solutions

SymptomCauseInstant Solution
GitCommandErrorshallow cloneSet fetch-depth: 0
English display onlylocale not setAdd locale: en
Very slow buildsProcessing many filesTemporarily disable with enabled: false
Advanced Configuration (Performance Optimization) ### Performance Optimization
plugins:
  - git-revision-date-localized:
      exclude:
        - archive/*
        - drafts/*
      custom_format: "%Y-%m-%d"
      strict: false  # Continue on errors
### Custom Format Examples - ISO format: `"%Y-%m-%dT%H:%M:%S%z"` - US format: `"%B %d, %Y"`