Nuxt.js: Custom error pages

Created on 5 Dec 2016  路  7Comments  路  Source: nuxt/nuxt.js

Took a look through the examples and couldn't find anything on creating/controlling error page (404, etc.)

This question is available on Nuxt.js community (#c31)
question

Most helpful comment

error.vue is only work on 1 level route, ex: /foo.
In multiple level route, the default page will display instead of the error.vue, ex: /foo/bar.
If I use function error({ statusCode: 404, message: 'Page not found' }), error.vue is not working too.

All 7 comments

Hi, that's right it not on the documentation yet but will comes soon but it's possible.

You need to create a /pages/_error.vue file.
There is an example here on how we use it on nuxtjs.org.

Is it possible to somehow change the value of title meta tag on error page?

I'm using nuxt 1.1.1 and the following snippet does not work for me in error.vue. It works in other pages however.

   head () {
      return {
        title: 'Error 404'
      };
    }

@jamesAtcodeninja probably no such hook in the error case, since it's a minimal setup.
(What if whatever caused the error runs when trying to render a page displaying the error)

error.vue is only work on 1 level route, ex: /foo.
In multiple level route, the default page will display instead of the error.vue, ex: /foo/bar.
If I use function error({ statusCode: 404, message: 'Page not found' }), error.vue is not working too.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lazycrazy picture lazycrazy  路  3Comments

mikekidder picture mikekidder  路  3Comments

gary149 picture gary149  路  3Comments

vadimsg picture vadimsg  路  3Comments

bimohxh picture bimohxh  路  3Comments