SEO Constraints Enforced by the Build System in AI Engineering from Scratch
The build system in rohitg00/ai-engineering-from-scratch enforces strict SEO constraints—including 60-character title limits, mandatory unique titles, required metadata fields, and non-empty validation—before generating static assets.
The static site generation pipeline for the AI Engineering from Scratch curriculum implements rigorous SEO validation within its build process. Located primarily in site/build.js, these constraints ensure every lesson and certification track meets search engine optimization standards before deployment. The system validates metadata integrity through automated checks that reject duplicates, enforce character limits, and mandate complete field populations.
Title Length Constraints
The seoTitleFor helper function in site/build.js implements the primary title length validation. This utility truncates any input string to a maximum of 60 characters, ensuring compliance with search engine display limits.
At approximately line 1098 of site/build.js, the build script validates that every lesson's seoTitle does not exceed this threshold. If any entry violates this constraint, the build throws an explicit error: Error('… title exceeds 60 characters').
The implementation trims whitespace, collapses multiple spaces, and slices strings that exceed the limit:
function seoTitleFor(title) {
const MAX = 60;
const clean = title.trim().replace(/\s+/g, ' ');
return clean.length <= MAX ? clean : clean.slice(0, MAX).trim();
}
Uniqueness and Duplicate Detection
The build system maintains a Set of encountered titles to prevent duplicate SEO metadata. At approximately line 1099, the script checks each lesson's seoTitle against this collection, throwing Error('Duplicate SEO lesson title: …') if a collision occurs. This ensures every URL has a unique, indexable title tag.
The same validation logic applies to certification tracks. At approximately line 1121, the build applies identical uniqueness checks to prevent track title collisions.
Required Metadata Fields
Around line 563 of site/build.js, the build process iterates through the lesson manifest to verify the presence of mandatory fields. Each entry must contain eight specific keys: path, title, seoTitle, description, excerpt, context, previous, and next.
By approximately line 572, the system asserts that title, seoTitle, description, and excerpt contain truthy, non-empty values. Any missing or blank field triggers a build failure, preventing incomplete metadata from reaching production.
Build Artifacts and Testing
Upon successful validation, the script generates site/lesson-seo.json and site/certification-seo.json at approximately lines 1197-1198. These files contain the finalized, validated metadata for all entries.
The site/test_build_artifacts.js test suite programmatically verifies these constraints through assertions that check title lengths, field presence, and uniqueness:
assert.ok(entry.title && entry.seoTitle && entry.description && entry.excerpt);
assert.ok(entry.seoTitle.length <= 60);
assert.ok(!new Set(lessonEntries.map(e => e.seoTitle)).has(entry.seoTitle));
These tests ensure that the SEO constraints enforced during the build process remain intact across code changes.
Summary
- The build system enforces a hard limit of 60 characters for all SEO titles through the
seoTitleForfunction insite/build.js. - Duplicate detection prevents title collisions across lessons and certification tracks using Set-based validation at lines ~1099 and ~1121.
- Eight required metadata fields must be present and populated:
path,title,seoTitle,description,excerpt,context,previous, andnext. - Validation occurs during the build process and is reinforced by unit tests in
site/test_build_artifacts.js. - Validated data persists to
lesson-seo.jsonandcertification-seo.jsonfor runtime consumption.
Frequently Asked Questions
What happens if a lesson title exceeds 60 characters?
The build system either automatically truncates the title using the seoTitleFor helper or throws an explicit error if the constraint is violated in the raw data. This prevents poorly formatted titles from reaching the generated lesson-seo.json artifact and ensures optimal search engine display.
Which metadata fields are mandatory for every lesson?
Every lesson must include path, title, seoTitle, description, excerpt, context, previous, and next keys with non-empty values. The build script validates these requirements at approximately line 563 of site/build.js, failing the build if any field is missing or empty.
How does the build system detect duplicate SEO titles?
The system maintains a Set containing all previously processed titles during the build process. When processing each lesson or certification track, it checks the current seoTitle against this Set, throwing an error immediately upon detecting any duplication to ensure unique indexable content across the entire site.
Where are the validated SEO artifacts stored?
After successful validation, the build script writes the processed metadata to site/lesson-seo.json and site/certification-seo.json at approximately lines 1197-1198. These files serve as the canonical data sources for the site's runtime SEO implementations and API endpoints.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →