如何在Next.js中命名一个文件夹,以使其在URL路径中被跳过?

huangapple go评论61阅读模式
英文:

How to name a folder in next js such that it is skipped in the url path?

问题

In my nextjs project, is it possible to ignore or skip a subfolder in the path of the url?

What I mean is, lets say I have a folder structure like this -

src

  • app
    • page1
      • page.tsx
    • page2
      • page.tsx
    • pagegroup (skip this in the url path)
      • insidepage1
        • page.tsx
      • insidepage2
        • page.tsx
      • insidepage3
        • page.tsx

I want insidepage to be accessed by url -

/insidepage1

/insidepage2

and not

/pagegroup/insidepage1

Is there a way to name a folder such that it becomes transparent? I did see it somewhere in a youtube tutorial but unfortunately can't remember or find that video now.

英文:

In my nextjs project, is it possible to ignore or skip a subfolder in the path of the url?

What I mean is, lets say I have a folder structure like this -

src
  - app
    - page1
       - page.tsx
    - page2
       - page.tsx
    - pagegroup (skip this in the url path)
       - insidepage1
          - page.tsx
       - insidepage2
          - page.tsx
       - insidepage3
          - page.tsx

i want insidepage to be accessed by url -

/insidepage1

/insidepage2

and not

/pagegroup/insidepage1

Is there a way to name a folder such that it becomes transparent? I did see it somewhere in a youtube tutorial but unfortunately can't remember or find that video now.

答案1

得分: 0

我找到了解决方法。
如果我将文件夹命名为(),它将变为透明。
所以我只需将pagegroup命名为(pagegroup),它就不会包含在URL路径中。

英文:

I found the solution.
If I name the folder in () it will become transparent.
So I can just name pagegroup to (pagegroup) and it won't be included in the url path.

huangapple
  • 本文由 发表于 2023年4月17日 21:57:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76035962.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定