Create New Blog Post

Static Route Priority Example

Route Priority Demonstration

This file: /blog/create.astro (static route)
Also exists: /blog/[slug].astro (dynamic route)
URL: /blog/create
Static route wins! Even though /blog/[slug].astro could match "create", the static route takes priority.

Astro Route Priority Rules

1

Static Routes

/blog/create.astro - Exact path matches, no parameters

2

Dynamic Routes (Named Params)

/blog/[slug].astro - Single parameter matches

3

Rest Parameter Routes

/blog/[...path].astro - Catch-all for any depth

Test Route Priority

Static Route (Higher Priority)

📝 /blog/create → This page (create.astro)

Dynamic Route (Lower Priority)

📄 /blog/my-first-post → [slug].astro

Notice how /blog/create goes to this page instead of treating "create" as a slug!

Implementation

// File structure:
pages/
  blog/
    create.astro         ← Static route (higher priority)
    [slug].astro         ← Dynamic route (lower priority)
    [...path].astro      ← Rest param route (lowest priority)

// URL: /blog/create
// Result: create.astro is served (static wins over dynamic)

// URL: /blog/my-post  
// Result: [slug].astro is served with slug="my-post"

// URL: /blog/category/tech/post-1
// Result: [...path].astro is served with path="category/tech/post-1"