This guide explains how to use the pre-commit hook that automatically checks your content before committing changes to the repository.
A pre-commit hook is an automated script that runs every time you try to commit changes. It helps maintain consistency and quality by catching common issues before they enter the codebase.
- New files: Automatically adds
dateandlastmodfields with the current timestamp - Modified files: Automatically updates the
lastmodfield to reflect when changes were made - Format: Uses ISO 8601 format with UTC timezone (e.g.,
2025-01-16T10:30:45+00:00) - No manual work needed: You no longer need to add or update these fields yourself!
- Ensures all tags match our approved taxonomy
- Checks that you haven't exceeded 5 tags per article
- Verifies proper capitalization (Title Case vs. acronyms)
- Catches typos and misspellings
- Ignores code blocks (between ```)
- Ignores Hugo shortcodes (e.g.,
{{< youtube >}}) - Ignores inline code (between `)
- Ignores URLs
- Uses a custom dictionary for technical terms
-
Install aspell (for spell checking):
# macOS brew install aspell # Ubuntu/Debian sudo apt install aspell # RHEL/CentOS/Fedora sudo yum install aspell # or sudo dnf install aspell # Alpine Linux apk add aspell # Arch Linux sudo pacman -S aspell
-
Enable the git hooks:
./setup-hooks.sh
That's it! The hook will now run automatically when you commit.
When you run git commit, you'll see output like this:
🔍 Running pre-commit checks...
📅 Updated lastmod dates for 1 file(s)
- content/chainguard/chainguard-images/getting-started.md
✅ All checks passed!
🔍 Running pre-commit checks...
📅 Added date fields to 1 new file(s)
- content/chainguard/new-tutorial.md
📄 content/chainguard/getting-started.md
Tags: ["Chainguard Containers", "Overview", "NewTag"]
⚠️ Tag not in approved list: 'NewTag'
📝 Spelling errors found:
- 'recieve' on line(s): 23
- 'configuation' on line(s): 45
============================================================
Pre-commit Check Summary:
Tag Warnings: 1
Tag Errors: 0
Files with spelling issues: 1
💡 Consider reviewing TAG_GUIDELINES.md for approved tags
📝 Spelling issues found. Consider:
- Fixing typos
- Adding technical terms to your personal dictionary
- Using 'git commit --no-verify' to skip this check
🔍 Running pre-commit checks...
📄 content/chainguard/tutorial.md
Tags: ["CHAINGUARD", "TUTORIAL"]
❌ Tag should use Title Case: 'CHAINGUARD'
❌ Tag should use Title Case: 'TUTORIAL'
============================================================
Pre-commit Check Summary:
Tag Warnings: 0
Tag Errors: 2
Files with spelling issues: 0
❌ Commit blocked due to tag errors. Please fix and try again.
When creating a new article, you no longer need to add date fields manually. Just focus on your content:
What you write:
---
title: "Getting Started with Chainguard Images"
description: "Learn how to use Chainguard's secure container images"
tags: ["Chainguard Containers", "Getting Started", "Overview"]
---What gets committed (automatically):
---
title: "Getting Started with Chainguard Images"
date: 2025-01-16T10:30:45+00:00
lastmod: 2025-01-16T10:30:45+00:00
description: "Learn how to use Chainguard's secure container images"
tags: ["Chainguard Containers", "Getting Started", "Overview"]
---When you modify an article, the lastmod field is automatically updated:
Before your edit:
---
title: "Security Best Practices"
date: 2024-12-01T09:00:00+00:00
lastmod: 2024-12-15T14:30:00+00:00
---After commit (automatic update):
---
title: "Security Best Practices"
date: 2024-12-01T09:00:00+00:00
lastmod: 2025-01-16T10:45:30+00:00
---If you see a tag error, update your frontmatter:
# ❌ Wrong
tags: ["chainguard containers", "OVERVIEW"]
# ✅ Correct
tags: ["Chainguard Containers", "Overview"]The spell checker might flag technical terms as errors. You have three options:
-
Fix actual typos:
recieve→receiveconfiguation→configuration
-
Add technical terms to the dictionary: If you're using a legitimate technical term that's flagged:
echo "MyTechnicalTerm" >> .aspell.en.pws
-
Skip the check (use sparingly):
git commit --no-verify -m "Your commit message"
Product Tags:
Chainguard ContainersChainguard Librarieschainctl
Content Types:
Overview- High-level introductionsProcedural- Step-by-step guidesConceptual- Theory/backgroundReference- API/command docsFAQ- Common questions
Action Tags:
Getting StartedMigrationConfigurationTroubleshootingIntegration
Platform Tags:
AWS,GCP,AzureKubernetesDocker HubGitHub,GitLab
For the complete list, see TAG_GUIDELINES.md.
Install aspell using your system's package manager:
# macOS
brew install aspell
# Ubuntu/Debian
sudo apt install aspell
# RHEL/CentOS/Fedora
sudo yum install aspell
# Alpine Linux
apk add aspell
# Arch Linux
sudo pacman -S aspellMake sure hooks are enabled:
git config core.hooksPath
# Should output: .githooksIf not, run:
./setup-hooks.shFor urgent commits where you need to bypass the check:
git commit --no-verify -m "Emergency fix"Note: Use this sparingly and fix any issues in a follow-up commit.
git config --unset core.hooksPath- Let automation handle dates: Never manually add or update
date/lastmodfields - the hook does this for you - Run checks early: Stage your files and run
git commiteven before writing a message to see if there are issues - Fix issues promptly: Don't use
--no-verifyas a habit - Keep tags minimal: Use 3-4 tags that truly describe the content
- Review spelling suggestions: The spell checker helps maintain professional documentation
- Use code blocks properly: Put commands and code in markdown code blocks (```) to avoid spelling false positives
- For tag questions: Review TAG_GUIDELINES.md
- For hook issues: Check with the engineering team
- For adding new approved tags: Submit a PR with justification
Remember: The hook is here to help maintain quality and consistency. It catches issues early, saving time in review and ensuring a better experience for our readers!