
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYou're not being stupid at all! This is a common question and there are several ways to handle prefixed slugs in Sanity.
The key thing to understand is that Sanity stores just the slug value (like "mens") in your content, and you handle the prefix (like "/category/") in your frontend routing code, not in Sanity itself.
Here are your main approaches:
Store just the slug value ("mens") in Sanity, then add the prefix in your frontend:
// In your schema
{
name: 'slug',
type: 'slug',
options: {
source: 'title'
}
}
// In your Next.js/frontend code
const categoryUrl = `/category/${category.slug.current}`;This keeps your content flexible - you can change URL patterns without updating content.
You can actually include the prefix directly in the slug using a custom slugify function in your schema:
{
name: 'slug',
type: 'slug',
options: {
source: 'title',
slugify: input => `/category/${input.toLowerCase().replace(/\s+/g, '-')}`
}
}Though this is less flexible if you want to change your URL structure later.
You can also construct the full path in your GROQ queries:
*[_type == "category"] {
title,
"fullPath": "/category/" + slug.current
}Bottom line: Most developers go with option #1 - store clean slugs in Sanity ("mens") and handle prefixes in your routing code (/category/${slug}). This keeps your content portable and your URL structure flexible. The slug field in Sanity is really just for storing the unique identifier part, not the full URL path.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store