Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/docs/src/routes/qwikcity/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
## Routing

- [Overview](routing/overview/index.mdx)
- [Index](routing/default-index/index.mdx)
- [Pathless Dirs](routing/pathless/index.mdx)
- [Route Parameters](routing/route-parameters/index.mdx)
- [Retrieving Data](endpoint/data/index.mdx)
- [Modifying Data](endpoint/modify/index.mdx)
- [Redirects](endpoint/redirects/index.mdx)
- [Error Responses](endpoint/error-responses/index.mdx)
- [Pathless Dirs](routing/pathless/index.mdx)

## Layout

Expand Down
17 changes: 11 additions & 6 deletions packages/docs/src/routes/qwikcity/routing/pathless/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ title: Qwik City - Pathless

# Qwik City - Pathless

At times components get so complex that using `index.ts` is not enough, and they need their own directory structure. In that case, Qwik City allows you to place the component into its own directory prefixed with `__`. Qwik City will then not use that directory name in the user URL.
Common purpose routes are often placed into directories so they can share layouts, and so related source files are logically grouped next to each other. However, it may be desirable that the directory, which was used to group similar files and share layouts, is excluded from the public facing URL. This is where "pathless" routes comes in.

By prefixing any directory name with two underscores `__`, then the directory name itself will not be included in the URL pathname.

For example, let's an app placed all accounts routes together in a directory, however, `/account/` could be dropped from the URL for cleaner, shorter URLs. In the example below, notice that the paths are within `src/routes/__accounts/` directory. However, the URL paths exclude `__accounts/`.

```
- src/
- routes/
- some/
- path/
- __complex-component/ # Notice the double underscore prefix
- index.tsx # https://example.com/some/path (the _complex-component folder is ignored)
- other_component.tsx # this file is ignored and not mapped to any URL because of the leading underscore.
- __accounts/ # Notice the double underscore prefix
- layout.tsx # Shared account layout
- profile/
-index.tsx # https://example.com/profile
- settings/
-index.tsx # https://example.com/settings
```