1
votes

I am building a Nuxt app that uses the WordPress REST API for content. All my other routes work fine, but I'm coming unstuck when it comes to nested pages.

I'm using the following structure in my Nuxt app:

pages
--- _slug
------ index.vue

In WordPress, an example would be:

How To Get There (slug: how-to-get-there)
-- Roads & Road Safety (slug: roads-road-safety)

I must be misunderstanding how routing works as this doesn't work and I get a 404 error when attempting to access the child page.

What is the correct way to route a child page from WordPress?

1
What url do you use?Krzysztof Atłasik
@KrzysztofAtlasik I use /parent/slug/ - eg: /how-to-get-here/roads-road-safetyAlxTheRed
Could you go more detail? I think you re not following the guideline from what i see from question. Could you take a photo or draw the folder pages structure ?Tran Son Hoang
@HoangTranSon What additional detail do you need?AlxTheRed
@AlxTheRed Give me the structure of pages. you should point out children folder and file vue. So that I can help you.Tran Son Hoang

1 Answers

0
votes

I read this from guideline of Nuxt.

"To define a dynamic route with a parameter, you need to define a .vue file OR a directory prefixed by an underscore."

So it should be

pages/ 
--| _slug/ 
-----| _slug.vue

Ref: Routing in Nuxt