👀 Our most exciting product launch yet 🚀 Join us May 8th for Sanity Connect

Is there any way to prefix a slug, ie category page for mens would be /category/mens?

2 replies
Last updated: Sep 17, 2020
Is there any way to prefix a slug, ie category page for mens would be /category/mens - it most likely me being stupid so points in the right direction would be helpful aswell
Sep 17, 2020, 8:54 PM
You could set up a custom source function to achieve this. For example:
{
  title: 'Slug',
  name: 'slug',
  type: 'slug',
  options: {
    source: doc => `/category/${doc.category}`
  }
}
Sep 17, 2020, 9:20 PM
That’s probably because the default
slugify
function replaces slashes. Something like this should get you closer 🙂
{
  title: 'Slug',
  name: 'slug',
  type: 'slug',
  options: {
    source: doc => `/category/${doc.category}`,
    slugify: input => input
      .toLowerCase()
      .slice(0, 200)
  }
}
Sep 17, 2020, 9:31 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?