Skip to content

getStaticPaths missing on dynamic Astro route

Astro is a static site generator by default. A file like src/pages/blog/[slug].astro signals a dynamic route, but without getStaticPaths() Astro has no list of URLs to build. The route does not appear in the output at all.

Export getStaticPaths() from the component frontmatter. It returns an array of { params, props } objects — one per page.

src/pages/blog/[slug].astro
---
export async function getStaticPaths() {
const posts = await getPosts()
return posts.map(post => ({
params: { slug: post.slug },
props: { post },
}))
}
const { post } = Astro.props
---
<html lang="en">
<head>
<title>{post.title}</title>
<meta name="description" content={post.excerpt} />
</head>
<body>
<h1>{post.title}</h1>
<p>{post.excerpt}</p>
</body>
</html>

If the content is truly dynamic — real-time data, user-generated content — switch to server-side rendering instead.

astro.config.ts
import { defineConfig } from 'astro/config'
import node from '@astrojs/node'
export default defineConfig({
output: 'server',
adapter: node({ mode: 'standalone' }),
})

With output: 'server', dynamic routes are rendered on request and getStaticPaths() is not required.

Run npx astro build and confirm the output directory contains the expected HTML files for each path. Then re-run orino audit.