Static Websites Overview
What are static websites
Section titled “What are static websites”Static websites deliver pre-rendered HTML, CSS, and JavaScript files exactly as they exist on disk. They shine when content changes infrequently or can be regenerated ahead of time. Because the server simply serves files (often cached on a CDN), static sites are fast, resilient, and inherently secure—there is no running application code to patch.
Key traits:
- Pre-rendered output: Pages are generated at build time and stored in a
dist,public, orbuilddirectory. - Lightweight hosting: Any object store or CDN can host the result (GitHub Pages, Netlify, Vercel, Azure Static Web Apps, Amazon S3 + CloudFront, Cloudflare Pages, etc.).
- Predictable performance: Requests are fulfilled from edge caches or simple web servers, minimizing latency and compute costs.
- Security surface: With no server-side runtime, attack vectors shrink to the web server and front-end code.
Static isn’t synonymous with “boring.” Modern static-site generators (SSGs) inject data at build time, hydrate interactive components on the client, and support partial revalidation for fresher content.
When to choose static
Section titled “When to choose static”| Scenario | Good Fit? | Notes |
|---|---|---|
| Marketing/landing pages | ✅ | Author in Markdown / CMS, deploy globally via CDN. |
| Documentation & knowledge bases | ✅ | Use markdown-first SSGs (Docusaurus, VitePress, MkDocs). |
| Blogs & content hubs | ✅ | Incremental builds keep large catalogs fresh. |
| E-commerce with dynamic inventory | ⚠️ | Pair SSG with client-side APIs or serverless functions. |
| Real-time dashboards | ❌ | Requires dynamic back end or SSR/Edge functions. |
Typical workflow
Section titled “Typical workflow”- Set up tooling
Install the runtime (Node.js, Go, Ruby, Python, etc.) and the SSG CLI (npm create astro@latest,hugo new site,jekyll new). - Scaffold a project
Start from an official starter or company template that establishes layout, styling, and docs structure. - Author content
Use Markdown/MDX, JSON/YAML data files, or CMS integrations. Modern SSGs support MDX (JSX in Markdown) for interactive components. - Develop locally
Run the dev server (npm run dev,hugo server,mkdocs serve) for hot reload and live previews. - Build for production
Generate the static output (npm run build,hugo,mkdocs build). Output lands in a folder (oftendist/,public/, orsite/). - Deploy
Ship the folder to a static host or CDN. Automate via GitHub Actions, Azure DevOps, or Netlify/Vercel build hooks.
Popular generators at a glance
Section titled “Popular generators at a glance”| Generator | Language | Strengths | Build command | Output folder |
|---|---|---|---|---|
| Astro | Node.js | Content sites, islands architecture, optional server routes | npm run build |
dist/ |
| Next.js static export | Node.js | React ecosystem; output: 'export' prerenders everything |
npm run build (next build) |
out/ |
| Hugo | Go | Very fast builds, single binary, flexible templating | hugo |
public/ |
| Jekyll | Ruby | Blog-centric, long GitHub Pages history | bundle exec jekyll build |
_site/ |
| Docusaurus | Node.js | Documentation with versioning and i18n | npm run build |
build/ |
| VitePress | Node.js | Lightweight docs with Vue components | npm run docs:build |
docs/.vitepress/dist/ |
| MkDocs | Python | Markdown docs from one mkdocs.yml |
mkdocs build |
site/ |
| Gatsby | Node.js | React with a GraphQL data layer | npm run build |
public/ |
Requirements, full command sequences, versions and pitfalls for each are on static site generators: create, run and build. For Astro, which this site is built with, there is a full Astro section.
Hosting and delivery options
Section titled “Hosting and delivery options”- Managed static hosts: Netlify, Vercel, Render Static, Fleek.
- Cloud services: Azure Static Web Apps, AWS Amplify Hosting, Google Firebase Hosting, Cloudflare Pages, GitHub Pages.
- DIY: Object storage + CDN (Azure Blob Storage static website + Azure Front Door, Amazon S3 + CloudFront, Cloud Storage + Cloud CDN).
When choosing a host, consider build minutes, preview environments, branch deploys, access control, and integration with your CI/CD platform.
Deployment pipelines
Section titled “Deployment pipelines”- GitHub Actions: Use
actions/setup-node+ framework-specific build steps, then deploy with the officialactions/upload-pages-artifactandactions/deploy-pagesactions for GitHub Pages (Astro wraps the build step inwithastro/action),Azure/static-web-apps-deployfor Azure Static Web Apps, or the host’s own Git integration. - Azure DevOps:
npm install,npm run build, publishdist/artifact, deploy with Azure Static Web Apps or Azure Storage tasks. - TeamCity/Jenkins: Keep builds deterministic, cache dependencies, and publish as pipeline artifacts before uploading to hosting providers.
Add smoke tests (link checks, Lighthouse audits) as post-build steps to catch regressions before shipping.
Enhancing static sites
Section titled “Enhancing static sites”- Edge functions: Inject dynamic behavior (forms, search, personalization) via serverless functions (Netlify Functions, Vercel Edge, Azure Functions).
- Incremental regeneration: For very large catalogs, some frameworks regenerate pages after deployment instead of rebuilding everything (Next.js Incremental Static Regeneration, Gatsby Deferred Static Generation). Both need a server or a supporting host, so they are not available in a pure static export.
- Content pipelines: Integrate headless CMS platforms (Contentful, Sanity, Strapi) to trigger builds when editors publish updates.
- Observability: Pair deployments with uptime checks, synthetic monitoring, and real user monitoring.
Related pages
Section titled “Related pages”- Static site generators: create, run and build: commands and pitfalls for eight generators.
- Astro introduction and Astro integrations, build and deploy
- Website hosting: custom domains and HTTPS certificates.