Introduction to Technical SEO for Developers
Running this script during CI gives you immediate feedback that the most basic SEO requirements are met.
Designing a Developer‑Centric SEO Architecture
This reduces TTFB dramatically and improves Core Web Vitals, both of which are ranking factors.
<h3>4. SEO Service Layer</h3> A set of utilities responsible for: <ul> <li>Generating <code>sitemap.xml</code> and <code>robots.txt</code> on each deployment.</li> <li>Injecting canonical, hreflang, and meta robots tags based on request context.</li> <li>Serializing structured data (JSON‑LD) from the data layer.</li> </ul> Having these in a dedicated module ensures consistency across micro‑services and simplifies testing. <h3>5. Monitoring & Alerting Layer</h3> Integrate Lighthouse CI, Screaming Frog API, or Google Search Console APIs into your CI pipeline. Example of a Lighthouse CI config that fails the build if LCP > 2.5 s: yaml ci: collect: url: https://staging.example.com settings: preset: desktop assert: assertions: largest-contentful-paint: maxScore: 0.9 minScore: 0.5Real‑World Example: Optimizing a Node.js E‑Commerce Platform
// Redirect www to non‑www and enforce HTTPS
app.use((req, res, next) => {
if (req.headers.host.startsWith('www.')) {
return res.redirect(301, https://${req.headers.host.slice(4)}${req.originalUrl});
}
if (req.protocol !== 'https') {
return res.redirect(301, https://${req.headers.host}${req.originalUrl});
}
next();
});
// Canonical slash handling - /products/123/ vs /products/123
app.use((req, res, next) => {
if (!req.path.endsWith('/') && !req.path.includes('.')) {
return res.redirect(301, ${req.path}/${req.url.slice(req.path.length)});
}
next();
});
module.exports = app;
The middleware runs before route handlers, guaranteeing that every request reaches the server in its canonical form.
<h3>Step 2 - Server‑Side Rendering with Next.js</h3> Next.js automatically provides SSR for pages that export `getServerSideProps`. For product pages we pull data from the same API the front‑end uses, then render the HTML on the server. ```js // pages/product/[slug].js import Head from 'next/head'; import fetch from 'node-fetch'; ```export async function getServerSideProps({ params }) {
const res = await fetch(${process.env.API_URL}/products/${params.slug});
const product = await res.json();
return { props: { product } };
}
export default function ProductPage({ product }) {
const jsonLd = {
'@context': 'https://schema.org/',
'@type': 'Product',
name: product.name,
image: product.images,
description: product.description,
sku: product.sku,
offers: {
'@type': 'Offer',
priceCurrency: 'USD',
price: product.price,
availability: 'https://schema.org/InStock',
url: https://example.com/product/${product.slug}
}
};
return (
<>
<Head>
<title>{product.name} - Example Store</title>
<meta name="description" content={product.shortDescription} />
<link rel="canonical" href={https://example.com/product/${product.slug}/} />
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />
</Head>
{/* page UI */}
</>
);
}
The <Head> component injects the title, meta description, canonical link, and structured data-all critical for SEO.
(async () => {
const res = await fetch(${process.env.API_URL}/products);
const products = await res.json();
const urls = products.map(p => <url><loc>https://example.com/product/${p.slug}/</loc><lastmod>${new Date(p.updatedAt).toISOString()}</lastmod><changefreq>weekly</changefreq><priority>0.8</priority></url>).join('\n');
const sitemap = <?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls}\n</urlset>;
fs.writeFileSync('public/sitemap.xml', sitemap);
// robots.txt - allow everything except admin routes
const robots = User-agent: *\nAllow: /\nDisallow: /admin/;
fs.writeFileSync('public/robots.txt', robots);
})();
Because the script writes to the public/ folder, both files are served directly from the CDN without extra server logic.
export default function Breadcrumbs({ items }) {
const jsonLd = {
'@context': 'https://schema.org',
'@type': 'BreadcrumbList',
itemListElement: items.map((item, i) => ({
'@type': 'ListItem',
position: i + 1,
name: item.name,
item: https://example.com${item.path}
}))
};
return (
<Head>
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />
</Head>
);
}
Embedding this component on any page instantly supplies search engines with hierarchical navigation data, which can appear as rich breadcrumbs in SERPs.
<h3>Step 5 - Performance Monitoring with Lighthouse CI</h3> Add a GitHub Action that runs Lighthouse on every pull request and fails if Core Web Vitals thresholds are not met. yaml name: Lighthouse CI on: [pull_request] jobs: lighthouse: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Install dependencies run: npm ci - name: Build & serve run: | npm run build npx serve -s out -l 5000 & sleep 5 - name: Run Lighthouse CI uses: treosh/lighthouse-ci-action@v9 with: urls: http://localhost:5000 configPath: ./.lighthouserc. ```js uploadArtifacts: true ```When the CI pipeline reports LCP > 2.5 s or a failed accessibility audit, developers get instant feedback and can address issues before they reach production.
<h3>Outcome</h3> Applying the above steps transformed the e‑commerce site: <ul> <li>Index coverage increased by 27 % (Google Search Console).</li> <li>Average LCP dropped from 3.2 s to 1.8 s (Lighthouse CI).</li> <li>Rich product snippets appeared for > 90 % of catalog pages.</li> </ul> These metrics illustrate how a developer‑oriented technical SEO strategy yields measurable SEO and UX gains.FAQs
Then verify that the Disallow rules do not match URLs you expect to be indexed.
Conclusion
The real‑world Node.js example demonstrates that a handful of well‑placed middleware, server‑rendered pages, and automated tooling can boost index coverage, improve Core Web Vitals, and unlock rich SERP features. When developers own these responsibilities, marketers receive a site that reliably performs at scale, and users enjoy faster, more informative experiences.
Adopt the patterns outlined in this guide, tailor them to your technology stack, and let your code be the engine that drives sustainable organic growth.
