How to disable certain Nuxt 3 pages?

2.3k Views Asked by At

Sometimes you have unfinished pages you don't want to make publicly available yet but you still want to publish the rest of your work.

You can either strictly work with feature branches, or you rename your page file ending into something like .txt, or you move them out of the pages directory.

Is it somehow possible to disable certain pages of your Nuxt 3 app?

2

There are 2 best solutions below

0
On

Have you tried using the .nuxtignore file?

# ignore layout foo.vue
layouts/foo.vue
# ignore layout files whose name ends with -ignore.vue
layouts/*-ignore.vue
# ignore page bar.vue
pages/bar.vue
# ignore page inside ignore folder
pages/ignore/*.vue
# ignore route middleware files under foo folder except foo/bar.js
middleware/foo/*.js
!middleware/foo/bar.js

https://nuxt.com/docs/guide/directory-structure/nuxtignore#nuxt-ignore-file

This seems to fit what you're trying to achieve.

0
On

you can add this settings file

nuxt.config.ts

  ignore:  [
        'components/web/**/*',
        'pages/auth/**/*',
        'pages/home/**/*',
        'pages/settings/**/*',
      ]