Git Hooks and Husky: Block Commits Without Valid MDX Frontmatter
Published October 25, 2026 by David
I just deployed five new articles to my Next.js blog. The content is sharp, the angle is on point. Yet, 48 hours later, Google Search Console is screaming. Why? A contributor forgot the description tag in an .mdx file’s frontmatter. Or worse, they wrote titre instead of title.
Result? An empty title tag, plummeting CTR in search results, and sometimes a client-side component crash due to a missing date field. All for an avoidable mistake.
The problem? Relying on human memory for technical SEO is like playing Russian roulette with your organic traffic. Notion guidelines? They gather dust. The only foolproof way to protect your customer acquisition is constraint: block errors before they leave your team’s machine.
The Pre-Commit Hook: Your SEO Safeguard
In B2B, organic growth depends on flawless technical execution. Just as the SEO of your PDFs dictates the survival of your social posts, the structure of your MDX files determines your Google indexing. A poorly formatted .mdx file means an empty title tag, a sinking CTR, and sometimes a broken client-side component.
The solution? Husky. This tool lets you leverage Git Hooks without friction. By combining Husky with a pre-commit check, you physically prevent committing an article that violates your SEO rules. The terminal flashes red, the commit is rejected, and the writer fixes their copy in 30 seconds.
Lock Down Your Project in 20 Minutes
Setting up a script to extract and validate your articles’ frontmatter at commit time takes 20 minutes. The tool scans modified files and verifies required fields: title, excerpt, date, cover image.
You can even enforce strict length validation. If the meta description exceeds 160 characters, the script halts the commit. No corrupted files slip into production—even if a freelance developer forgets a tag.
Technical Automation Must Serve Visual Execution
I’ve secured my blog’s textual structure. Brutal, pragmatic, unyielding.
But B2B content doesn’t live in markdown files alone. To attract qualified leads and dominate LinkedIn, I need visuals. If I protect my time with code-side scripts, I won’t waste it manually dragging text blocks in Figma for three hours. My creative process demands the same rigor as my Git workflow.
Les illustrations de ce blog sont généreusement mises à disposition par les photographes d' Unsplash.