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

296
Views
How to get the error (404) page into the ''dist" directory in nuxt?

I created an error page as in the documentation and it works.

https://nuxtjs.org/docs/2.x/concepts/views#error-page

In short, I create an error.vue file in the /layouts directory and optionally pass it a custom layout.

<template>
  <div>
    <h1 v-if="error.statusCode === 404">Page not found</h1>
    <h1 v-else>An error occurred</h1>
    <NuxtLink to="/">Home page</NuxtLink>
  </div>
</template>

<script>
  export default {
    props: ['error'],
    layout: 'error' // custom layout
  }
</script>

But my product task requires the 404 page to go into the /dist directory after the generate command.

Like this

dist/
--| 200.html
--| 404.html //do not exist for me

The following solutions didn't help:

  1. If I just add a 404 page to the /pages directory, then Nuxt will still show its default error page.

Is there a laconic way to do this? Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I managed to solve my problem by adding this code to nuxt.config.js.

router: {
  extendRoutes(routes, resolve) {
    routes.push({
      name: 'custom',
      path: '*',
      component: resolve('@/pages/404.vue')
    })
  }
},

Now 404.vue is in the /pages directory, and the 404.html page is in the /dist directory.

Documentation: https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-router#extendroutes

about 4 years ago · Juan Pablo Isaza 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!