Skip to content
building-static-sites logo

Building Static Sites

building-static-sites

Use when creating static websites with Next.js static export - covers YAML-based content, image optimization, form handling, SEO, and deployment to GitHub Pages/Netlify/Vercel

SKILL.md

Full skill instructions

Building Static Sites

Overview

Static site generation with Next.js (output: 'export') for marketing sites, documentation, portfolios, and blogs.

Extends building-with-nextjs for static export.

When to Use

  • Marketing sites, docs, blogs, portfolios, landing pages
  • No auth, no server-side logic, no real-time data

Configuration

next.config.ts:

const nextConfig = {
  output: 'export',  // Enable static HTML export
  images: {
    unoptimized: true,  // Or use optimizer plugin
  },
}

Build output: out/ directory with static HTML

YAML-Based Content (Recommended)

Structure:

content/
├── global.yaml          # Site-wide content
├── features.yaml        # Reusable blocks
└── pages/
    ├── home.yaml
    ├── about.yaml
    └── contact.yaml

Type-safe loading:

// lib/​content-types.ts
export interface GlobalContent {
  site: { title: string; description: string; url: string }
  navigation: { links: Array<{ href: string; label: string }> }
}

// lib/​content.ts
import fs from 'fs'
import path from 'path'
import yaml from 'js-yaml'

export function getGlobalContent(): GlobalContent {
  const filePath = path.join(process.cwd(), 'content', 'global.yaml')
  const content = fs.readFileSync(filePath, 'utf8')
  return yaml.load(content) as GlobalContent
}

Example YAML:

# content/​global.yaml
site:
  title: "My Company"
  description: "We build great things"

navigation:
  links:
    - href: "/"
      label: "Home"
    - href: "/​about"
      label: "About"

Usage:

// app/​page.tsx
import { getHomeContent } from '@/​lib/​content'

export default function HomePage() {
  const content = getHomeContent()
  return <h1>{content.hero.headline}</​h1>
}

Dependencies:

pnpm add js-yaml
pnpm add -D @types/​js-yaml

Image Optimization

Option 1: Pre-optimize manually

pnpm add -D sharp-cli
sharp resize 1920 --quality 85 --format webp public/​images/​*.{jpg,png}

Option 2: Build-time optimization

pnpm add -D next-image-export-optimizer

Option 3: CDN-based (Recommended)

  • Use Cloudflare Images, imgix, or similar
  • No build processing needed

Form Handling

See integrating-formspree-forms skill for complete setup.

Quick example:

'use client'
import { useForm } from '@formspree/​react'

export default function ContactForm() {
  const [state, handleSubmit] = useForm("YOUR_FORM_ID")

  if (state.succeeded) {
    return <p>Thanks for your message!</​p>
  }

  return (
    <form onSubmit={handleSubmit}>
      <input type="email" name="email" required />
      <textarea name="message" required />
      <button type="submit">Send</​button>
    </​form>
  )
}

SEO

Metadata configuration:

// app/​layout.tsx
import type { Metadata } from 'next'

export const metadata: Metadata = {
  title: { default: 'My Site', template: '%s | My Site' },
  description: 'Site description',
  openGraph: {
    title: 'My Site',
    description: 'Site description',
    images: [{ url: 'https://example.com/​og-image.png' }],
  },
}

Sitemap generation:

// app/​sitemap.ts
import type { MetadataRoute } from 'next'

export default function sitemap(): MetadataRoute.Sitemap {
  return [
    {
      url: 'https://example.com',
      lastModified: new Date(),
      priority: 1,
    },
  ]
}

robots.txt:

// app/​robots.ts
export default function robots() {
  return {
    rules: { userAgent: '*', allow: '/' },
    sitemap: 'https://example.com/​sitemap.xml',
  }
}

Testing

Content validation:

// scripts/​validate-yaml.js
import fs from 'fs'
import yaml from 'js-yaml'

function validateYaml(filePath) {
  try {
    const content = fs.readFileSync(filePath, 'utf8')
    yaml.load(content)
    console.log(`✅ ${filePath}`)
  } catch (error) {
    console.error(`❌ ${filePath}: ${error.message}`)
    process.exit(1)
  }
}

Build verification:

// scripts/​verify-build.js
import fs from 'fs'
import path from 'path'

const requiredPages = ['index.html', 'about/​index.html']

requiredPages.forEach(page => {
  const fullPath = path.join(process.cwd(), 'out', page)
  if (!fs.existsSync(fullPath)) {
    console.error(`❌ Missing: ${page}`)
    process.exit(1)
  }
})
console.log('✅ Build verification passed')

Deployment

GitHub Pages:

# .github/​workflows/​deploy.yml
name: Deploy

on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/​checkout@v4
      - uses: pnpm/​action-setup@v2
      - run: pnpm install
      - run: pnpm build
      - uses: actions/​upload-pages-artifact@v3
        with:
          path: ./​out

Netlify:

# netlify.toml
[build]
  command = "pnpm build"
  publish = "out"

Vercel: Auto-detects Next.js, no config needed.

justfile Commands

build-static:
    pnpm build
    @echo "✅ Static site built to ./​out"

validate-content:
    node scripts/​validate-yaml.js

verify-build:
    node scripts/​verify-build.js

check-all: format lint typecheck validate-content test coverage test-e2e a11y verify-build
    @echo "✅ All static site checks passed"

Limitations & Workarounds

No dynamic content:

  • ✅ Use client-side fetching for dynamic data
  • ✅ Rebuild site periodically (scheduled CI)

No API routes:

  • ✅ Use third-party services (Formspree, Supabase)

Image optimization disabled:

  • ✅ Use CDN-based optimization
  • ✅ Pre-optimize with sharp-cli

More Marketing skills

copywriting logo
Marketing

copywriting

Marketing copy for homepages, landing pages, pricing pages, and other conversion-focused web pages.

53.3K 216.1K
View
flux-2-klein logo
Marketing

flux-2-klein

Fast image generation with Flux 2 Klein, optimized for sub-second iteration and multi-reference brand styling.

52 176.2K
View

Psychological principles and mental models for understanding customer behavior and influencing marketing decisions.

53.3K 153K
View

Plan searchable and shareable content that drives traffic, builds authority, and generates leads.

53.3K 150.9K
View

Build SEO-optimized pages at scale using templates, data, and proven playbook patterns.

53.3K 140.1K
View

Brainstorm and prioritize marketing strategies tailored to your SaaS stage, budget, and goals.

53.3K 137.2K
View
ai-seo logo
Marketing

ai-seo

Optimize content for discovery, citation, and visibility across AI search platforms and LLM assistants.

53.3K 136.7K
View
copy-editing logo
Marketing

copy-editing

Systematic improvement of existing marketing copy through seven focused editing passes.

53.3K 136.4K
View

Plan and optimize your website's page hierarchy, navigation, URL structure, and internal linking.

53.3K 112.8K
View
revops logo
Marketing

revops

Design and optimize systems connecting marketing, sales, and customer success into a unified revenue engine.

53.3K 104.9K
View

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

179.7K 100.1K
View

Convert websites into professional HyperFrames videos with guided storyboarding and brand-aligned composition.

57K 93.5K
View

Sales & marketing AI tools

KreadoAI logo
Sales & marketing

KreadoAI

Revolutionize Video Creation with AI-Generated Avatars and Voices

Paid
View
Followr logo
Sales & marketing

Followr

Social media on autopilot

Paid
View
Logodiffusion logo
Sales & marketing

Logodiffusion

Design custom logos instantly with AI.

Paid
View
I
Sales & marketing

Ideogram

Text-heavy marketing and design images

Freemium
View
Prompt Silo logo
Sales & marketing

Prompt Silo

Boost Your SEO with Content and SEO Silos

Free
View
Marketing Blocks logo
Sales & marketing

Marketing Blocks

Revolutionize Your Marketing with AI-Powered MarketingBlocks!

Paid
View
Scrip AI logo
Sales & marketing

Scrip AI

10X faster & free AI content creation for 100+ use cases

Free
View
Tribescaler logo
Sales & marketing

Tribescaler

Tribescaler | Make Your Tweets Go Viral

Paid
View