Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

02-app > 01-building-your-application > 01-routing > 04-route-groups.mdx 번역 #241

Merged
merged 5 commits into from
Jun 28, 2023
Merged
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
Original file line number Diff line number Diff line change
@@ -1,78 +1,80 @@
---
title: Route Groups
description: Route Groups can be used to partition your Next.js application into different sections.
title: 라우트 그룹
description: 라우트 그룹을 사용하여 Next.js 애플리케이션을 여러 섹션으로 나누기
---

In the `app` directory, nested folders are normally mapped to URL paths. However, you can mark a folder as a **Route Group** to prevent the folder from being included in the route's URL path.
`app` 디렉토리에서 중첩된 폴더는 일반적으로 URL 경로에 매핑됩니다. 이를 원치 않는다면, 원하는 폴더를 **라우트 그룹**으로 지정해 폴더를 라우트의 URL 경로에 포함되는 것을 막을 수 있습니다.

This allows you to organize your route segments and project files into logical groups without affecting the URL path structure.
이를 통해 URL 경로 구조에 영향을 주지 않고 라우트 세그먼트와 프로젝트 파일들을 논리적으로 구성할 수 있습니다.

Route groups are useful for:
라우트 그룹은 다음과 같은 경우에 유용하게 사용할 수 있습니다:

- [Organizing routes into groups](#organize-routes-without-affecting-the-url-path) e.g. by site section, intent, or team.
- Enabling [nested layouts](/docs/app/building-your-application/routing/pages-and-layouts) in the same route segment level:
- [Creating multiple nested layouts in the same segment, including multiple root layouts](#creating-multiple-root-layouts)
- [Adding a layout to a subset of routes in a common segment](#opting-specific-segments-into-a-layout)
- [URL 경로에 영향을 주지 않고 라우트를 그룹화하고 싶을 경우](#organize-routes-without-affecting-the-url-path) 예: 사이트 섹션, 의도, 팀별로 그룹화합니다.
- [동일한 라우트 세그먼트 수준에서 중첩된 레이아웃을 활성화할 수 있습니다:](/docs/app/building-your-application/routing/pages-and-layouts)
- [동일한 세그먼트에서 루트 레이아웃을 포함하여 중첩된 레이아웃을 생성할 경우](#creating-multiple-root-layouts)
- [일부 라우트에 레이아웃을 추가할 경우](#opting-specific-segments-into-a-layout)

## Convention
## 컨벤션

A route group can be created by wrapping a folder's name in parenthesis: `(folderName)`
라우트 그룹은 폴더 이름을 괄호로 감싸서 만들 수 있습니다: `(folderName)`

## Examples
## 예시

### Organize routes without affecting the URL path
### URL 경로에 영향을 주지 않고 라우트 구성하기

To organize routes without affecting the URL, create a group to keep related routes together. The folders in parenthesis will be omitted from the URL (e.g. `(marketing)` or `(shop)`).
URL 경로에 영향을 주지 않고 라우트를 구성하려면 관련 라우트를 모아 그룹으로 지정합니다. 괄호 안에 있는 폴더들은 URL 경로에서 제외됩니다. (예: `(marketing)` 혹은 `(shop)`)

<Image
alt="Organizing Routes with Route Groups"
alt="라우트를 라우트 그룹으로 조직화하기"
srcLight="/docs/light/route-group-organisation.png"
srcDark="/docs/dark/route-group-organisation.png"
width="1600"
height="930"
/>

Even though routes inside `(marketing)` and `(shop)` share the same URL hierarchy, you can create a different layout for each group by adding a `layout.js` file inside their folders.
`(marketing)` `(shop)` 안에 있는 라우트들은 같은 위계를 가지고 있더라도, 폴더 내에 `layout.js` 를 추가하여 그룹에 각자 다른 레이아웃을 만들 수 있습니다.

<Image
alt="Route Groups with Multiple Layouts"
alt="다중 레이아웃으로 구성된 라우트 그룹"
srcLight="/docs/light/route-group-multiple-layouts.png"
srcDark="/docs/dark/route-group-multiple-layouts.png"
width="1600"
height="768"
/>

### Opting specific segments into a layout
### 특정 세그먼트를 레이아웃으로 설정하기

To opt specific routes into a layout, create a new route group (e.g. `(shop)`) and move the routes that share the same layout into the group (e.g. `account` and `cart`). The routes outside of the group will not share the layout (e.g. `checkout`).
특정 라우트를 레이아웃으로 설정하려면 새로운 라우트 그룹 (예: `(shop)`)을 만들고, 동일한 레이아웃을 적용할 라우트들을 그룹 안으로 넣습니다 (예: `account` `cart`). 그룹 밖에 있는 라우트들은 그룹 레이아웃이 적용되지 않습니다. (예: `checkout`)

<Image
alt="Route Groups with Opt-in Layouts"
alt="옵트인(Opt-in) 레이아웃이 적용된 라우트 그룹"
srcLight="/docs/light/route-group-opt-in-layouts.png"
srcDark="/docs/dark/route-group-opt-in-layouts.png"
width="1600"
height="930"
/>

### Creating multiple root layouts
### 다중 루트 레이아웃 만들기

To create multiple [root layouts](/docs/app/building-your-application/routing/pages-and-layouts#root-layout-required), remove the top-level `layout.js` file, and add a `layout.js` file inside each route groups. This is useful for partitioning an application into sections that have a completely different UI or experience. The `<html>` and `<body>` tags need to be added to each root layout.
여러 개의 [루트 레이아웃](/docs/app/building-your-application/routing/pages-and-layouts#root-layout-required)을 만들려면 가장 상위 폴더의 `layout.js` 파일을 삭제하고, 각각의 라우트 그룹에 `layout.js` 파일을 추가합니다.

<Image
alt="Route Groups with Multiple Root Layouts"
alt="다중 루트 레이아웃이 적용된 라우트 그룹"
srcLight="/docs/light/route-group-multiple-root-layouts.png"
srcDark="/docs/dark/route-group-multiple-root-layouts.png"
width="1600"
height="687"
/>

In the example above, both `(marketing)` and `(shop)` have their own root layout.
위의 예시에서 `(marketing)` `(shop)` 라우트에는 각자의 루트 레이아웃이 적용됩니다.

---

> **Good to know**:
> **참고**:
>
> - The naming of route groups has no special significance other than for organization. They do not affect the URL path.
> - Routes that include a route group **should not** resolve to the same URL path as other routes. For example, since route groups don't affect URL structure, `(marketing)/about/page.js` and `(shop)/about/page.js` would both resolve to `/about` and cause an error.
> - If you use multiple root layouts without a top-level `layout.js` file, your home `page.js` file should be defined in one of the route groups, For example: `app/(marketing)/page.js`.
> - Navigating **across multiple root layouts** will cause a **full page load** (as opposed to a client-side navigation). For example, navigating from `/cart` that uses `app/(shop)/layout.js` to `/blog` that uses `app/(marketing)/layout.js` will cause a full page load. This **only** applies to multiple root layouts.
> - 라우트 그룹의 이름은 그룹화를 통한 정리를 위한 것일뿐, 다른 특별한 의미는 없습니다. 라우트 그룹의 이름이 URL 경로에 영향을 주지 않습니다.
> - 다른 라우트 그룹을 포함하는 라우트는 다른 라우트와 같은 URL 경로로 귀결되면 **안됩니다.** 예를 들어, 라우트 그룹은 URL 구조에 영향을 주지 않으므로 `(marketing)/about/page.js` 파일과 `(shop)/about/page.js` 파일 모두 `/about` 경로에 귀결되어 에러를 발생시킵니다.
> - 최상위 폴더에 `layout.js` 파일 없이 루트 레이아웃을 여러 개 사용하는 경우, `app/(marketing)/page.js` 처럼 `page.js` 파일이 라우트 그룹 중 하나에 정의되어야 합니다.
> - **여러 루트 레이아웃**을 거쳐 탐색하는 경우, 클라이언트 측 탐색과 달리 **전체 페이지 로드**(full page load)가 됩니다. 예를 들어, `app/(shop)/layout.js` 파일을 사용하는 `/cart` 에서부터 `app/(marketing)/layout.js` 파일을 사용하는 `/blog` 으로 이동하면 전체 페이지 로딩이 발생합니다. 이것은 **다중 루트 레이아웃이 있을 때만** 적용됩니다.
>
> [def]: #opting-specific-segments-into-a-layout