Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

973
Views
Error: A required parameter (slug) was not provided as an array in getStaticPaths for /posts/[...slug]

I have a problem with the 'getStaticPaths' function. When I try to get a dynamic display with a parameter it shows me as error: Error: A required parameter (slug) was not provided as an array in getStaticPaths for /posts/[...slug]

In My utils.js file got this function read the files

export function getPostsFiles() {
const postsDirectory = path.join(process.cwd(), "posts");

return fs.readdirSync(postsDirectory);
}

In my page [...slug]

export function getStaticProps(context) {
  const { params } = context;
  const { slug } = params;

  const postData = getPostData(slug);

  return {
    props: {
      post: postData,
    },
    revalidate: 600,
  };
}

export function getStaticPaths() {
  const postFilenames = getPostsFiles();

  const slugs = postFilenames.map((fileName) => fileName.replace(/\.md$/, ""));
  const parameters = slugs.map((slug) => ({ params: { slug: slug } }));

  return {
    paths: parameters,
    fallback: true,
  };
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Change your file name from [...slug] to [slug].

That should solve it.

about 4 years ago · akinyemi akinlabi Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!