Validation

Content validation and health checks

1 page in this section

Ensure content quality with health checks and automatic fixes.

Do I Need This?

Note

Skip this if: You manually check all links and content.
Read this if: You want automated quality assurance and CI/CD integration.

Validation Flow

flowchart LR A[Content] --> B[Validators] B --> C{Issues?} C -->|Yes| D[Report] C -->|No| E[Pass] D --> F{Auto-fixable?} F -->|Yes| G[Auto-fix] F -->|No| H[Manual fix needed]

Quick Start

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Run all checks
bengal validate

# Validate specific files
bengal validate --file content/page.md

# Only validate changed files
bengal validate --changed

# Verbose output (show all checks)
bengal validate --verbose
1
2
3
4
5
# Preview fixes
bengal fix --dry-run

# Apply fixes
bengal fix

Fixes common issues:

  • Missing frontmatter fields
  • Broken relative links
  • Incorrect slugs
1
2
# Fail build on issues
bengal build --strict

The--strictflag makes warnings into errors.

Built-in Checks

Check What it validates
links Internal and external links work
assets Asset references exist
config Configuration is valid
navigation Menu structure is correct
rendering Templates render without errors
cross_ref Cross-references are valid
taxonomy Tags and categories are consistent

Custom Validators

Create project-specific rules by extendingBaseValidator:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# validators/custom.py
from bengal.health.base import BaseValidator
from bengal.health.report import CheckResult

class RequireAuthorValidator(BaseValidator):
    """Validator that checks for author field in frontmatter."""

    name = "Author Required"
    description = "Ensures all pages have an author field"

    def validate(self, site, build_context=None):
        results = []
        for page in site.pages:
            if not page.metadata.get("author"):
                results.append(CheckResult.error(
                    f"Missing author field in {page.source_path}",
                    recommendation="Add 'author: Your Name' to frontmatter"
                ))
        return results

Tip

CI integration: Addbengal validateto your CI pipeline to catch issues before deployment. Use--verboseto see all checks, not just problems.