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

905
Views
Nuxt 3 custom layout shows Invalid layout selected

I am trying to add a custom layout in a Nuxt 3 project, but that layout doesn't work, and the console shows this message:

Invalid layout test_layout selected

There is no other error.

This the code I have tried:

-| layouts/
 ---| test_layout.vue
-| pages/
 ---| blog/index.vue
<template>
  <div>
    My Test Layout Header
    <slot />
  </div>
</template>
<script>
export default {
  name: "test_layout"
}
</script>
<template>
  <div>
    <p>My Blog Title</p>
  </div>
</template>

<script>
export default {
  layout:"test_layout",
  name: "blog",
}
</script>

I have tried <Nuxt/> instead of <slot />, but it's not working.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Nuxt 3 seems to replace the filename's underscore with hyphens, so the layout should be specified as test-layout:

// blog/index.vue
export default {
  // layout: 'test_layout', // ❌ replace underscore with hyphen

  layout: 'test-layout', // ✅
}

demo

This wasn't an issue in Nuxt 2, which uses the exact filename as the layout name (including underscores). I also don't see any documentation about this. I've reported the issue to get some clarification.

over 4 years ago · Santiago Trujillo Report

0

Remove below code from your layout file. This may work.

<script>
    export default {
      name: "test_layout"
    }
</script>
over 4 years ago · Santiago Trujillo 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!