rsnext/errors/conflicting-ssg-paths.md
Maedah Batool 60488e68e3
Fix broken data fetching links in docs (#33766)
* Fix broken links for Data Fetching

* Fix link data fetching doc

* Improve link file paths

* Update errors/large-page-data.md

Co-authored-by: Steven <steven@ceriously.com>

* Update links

* Fix linting

* Lint tests

* Lint tests

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2022-04-22 14:03:07 +02:00

1.5 KiB

Conflicting SSG Paths

Why This Error Occurred

In your getStaticPaths function for one of your pages you returned conflicting paths. All page paths must be unique and duplicates are not allowed.

Possible Ways to Fix It

Remove any conflicting paths shown in the error message and only return them from one getStaticPaths.

Example conflicting paths:

// pages/hello/world.js
export default function Hello() {
  return 'hello world!'
}

// pages/[...catchAll].js
export const getStaticProps = () => ({ props: {} })

export const getStaticPaths = () => ({
  paths: [
    // this conflicts with the /hello/world.js page, remove to resolve error
    '/hello/world',
    '/another',
  ],
  fallback: false,
})

export default function CatchAll() {
  return 'Catch-all page'
}

Example conflicting paths:

// pages/blog/[slug].js
export const getStaticPaths = () => ({
  paths: ['/blog/conflicting', '/blog/another'],
  fallback: false,
})

export default function Blog() {
  return 'Blog!'
}

// pages/[...catchAll].js
export const getStaticProps = () => ({ props: {} })

export const getStaticPaths = () => ({
  paths: [
    // this conflicts with the /blog/conflicting path above, remove to resolve error
    '/blog/conflicting',
    '/another',
  ],
  fallback: false,
})

export default function CatchAll() {
  return 'Catch-all page'
}