CONTENT VALIDATION

ENSURE CONTENT INTEGRITY

Validate content files for syntax errors, missing fields, and broken links before deployment.

VALIDATION COMMAND

Check content integrity
Basic Usage:
BASH
# Validate all content
./fyt validate

# Strict mode (fails on warnings)
./fyt validate --strict

# Validate specific file
./fyt validate content/pages/about.yaml
What Gets Validated:
YAML syntax validity
Required fields present (meta, title, etc.)
No markdown headings in content fields
Slug uniqueness
Internal link validity
File naming conventions
Indentation consistency

VALIDATION OUTPUT

Understanding results
Success Output:
TEXT
Validating content...

✓ content/pages/about.yaml
✓ content/pages/build.yaml
✓ content/pages/home.yaml
✓ content/blog/2025-01-15-welcome.yaml

4 files valid, 0 errors
Error Output:
TEXT
Validating content...

✓ content/pages/about.yaml
✗ content/pages/pricing.yaml
  Line 5: Missing required field: meta.description
  Line 12: Invalid slug format: /pricing/
  Line 25: Inconsistent indentation (expected 2 spaces)
✓ content/pages/home.yaml

2 files valid, 1 file with errors

COMMON ERRORS

How to fix them
Missing Required Fields:
Error: Missing required field: meta.description
Fix:
YAML
meta:
  title: "Page Title"
  description: "Add description here"  # Add this
  slug: "/page"
Invalid YAML Syntax:
Error: YAML syntax error: mapping values are not allowed here
Fix: Check for missing colons, quotes, or indentation
YAML
# Wrong
title "Page Title"

# Correct
title: "Page Title"
Inconsistent Indentation:
Error: Inconsistent indentation (expected 2 spaces)
Fix: Use 2 spaces consistently
YAML
# Wrong (mixed tabs/spaces)
sections:
	- id: "section-1"
    title: "Title"

# Correct (2 spaces)
sections:
  - id: "section-1"
    title: "Title"
Duplicate Slugs:
Error: Duplicate slug: /about
Fix: Make slugs unique
YAML
# Change one of the slugs
meta:
  slug: "/about-us"  # Instead of /about
Markdown Headings in Content:
Error: Markdown heading found in content field: ## Heading
Fix: Remove markdown headings, use bold text instead
YAML
# Wrong - redundant heading
content: |
  ## Command Syntax
  Use this command...

# Correct - bold label
content: |
  **Command Syntax:**
  Use this command...
Why: Section titles already provide heading hierarchy. Markdown headings in content create duplicate, conflicting headings.

VALIDATION WORKFLOW

Best practices
Before Committing:
BASH
# 1. Edit content
vi content/pages/about.yaml

# 2. Validate
./fyt validate

# 3. Fix errors
vi content/pages/about.yaml

# 4. Validate again
./fyt validate

# 5. Commit when clean
git add content/pages/about.yaml
git commit -m "Update about page"
CI/CD Integration:
BASH
# In CI pipeline
./fyt validate --strict

# Fails build if errors found
Pre-commit Hook:
BASH
# .git/hooks/pre-commit
#!/bin/bash
./fyt validate --strict
if [ $? -ne 0 ]; then
  echo "Validation failed. Fix errors before committing."
  exit 1
fi

NEXT STEPS

Learn More: