Nuxt.js: `nuxt generate` doesn't generate HTML file for pages with child routes

Created on 15 Dec 2018  Β·  8Comments  Β·  Source: nuxt/nuxt.js

Version

v2.3.4

Reproduction link

https://github.com/Justineo/nuxt-generate-bug

Steps to reproduce

  1. Creating a project with create-nuxt-app
  2. Create following pages:

    pages
    β”œβ”€ ...
    β”œβ”€ test
    β”‚  └─ foo.vue
    └─ test.vue
    
  3. Run nuxt generate

What is expected ?

In dist directory, there will be independent entry HTML file for both /test and /test/foo:

pages
β”œβ”€ ...
β”œβ”€ test
β”‚  └─ foo.html
└─ test.html

What is actually happening?

Entry for route path /test is missing:

pages
β”œβ”€ ...
└─ test
   └─ foo.html
This bug report is available on Nuxt community (#c8315)
bug-report pending

Most helpful comment

This has caused us a lot of trouble. The workaround I have is causing a significant copy-paste of files.

All 8 comments

If I understand the related docs, you're just creating a nested route (like vanilla Vue-Router does), not really creating the routed for /test.

Have you tried something like this?

pages
β”œβ”€ ...
└─ test
   β”œβ”€ foo.vue
   └─ index.vue

Or this?

pages
β”œβ”€ ...
β”œβ”€ test
β”‚  β”œβ”€ foo.vue
β”‚  └─ index.vue
└─ test.vue

Thanks, Leo. I'm able to workaround this as you suggested by creating a separate index.vue inside the test directory. But it did create the route for /test without /test/index.vue in the dev mode (See below).

image

And there is another problem.

pages
β”œβ”€ ...
└─ test
   β”œβ”€ foo.vue
   └─ index.vue

This seems to make /test and /test/foo siblings instead of parent/child, which breaks nested routes.

pages
β”œβ”€ ...
β”œβ”€ test
β”‚  β”œβ”€ foo.vue
β”‚  └─ index.vue
└─ test.vue

While this will lead to duplication.

I still think it's a problem of nuxt generate itself. It's not producing same result as the server-rendered version.

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as πŸ•Pending will not be automatically marked as stale.

Still experiencing this in the latest version of nuxt-edge.

Reproduction step is the same as mentioned in https://github.com/nuxt/nuxt.js/issues/4562#issue-391398271.

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as πŸ•Pending will not be automatically marked as stale.

This has caused us a lot of trouble. The workaround I have is causing a significant copy-paste of files.

I was bit by this too. I've found a very easy workaround.
Assume that /a works, /a/b doesn't and /a/b/c does for example. Add /a/b to your nuxt.config.js like so:

module.exports = {
  // ... the rest of your here ...

  // Workaround for nuxt bug #4562 (https://github.com/nuxt/nuxt.js/issues/4562)
  generate: {
      routes: [
        '/a/b',
      ]
    },
}

And it will generate that page too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bimohxh picture bimohxh  Β·  3Comments

bimohxh picture bimohxh  Β·  3Comments

shyamchandranmec picture shyamchandranmec  Β·  3Comments

gary149 picture gary149  Β·  3Comments

nassimbenkirane picture nassimbenkirane  Β·  3Comments