---
title: Writing document path expressions
related:
  - https://docs.kentico.com/k8/developing-websites/loading-and-displaying-data-on-websites/loading-document-data.md
  - https://docs.kentico.com/k8/configuring-kentico/configuring-page-urls/setting-document-aliases.md
  - https://docs.kentico.com/k8/configuring-kentico/configuring-page-urls.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

Path expressions allow you to select a set of documents from the content tree of Kentico websites. The expressions are based on the [alias path](https://docs.kentico.com/k8/configuring-kentico/configuring-page-urls/setting-document-aliases.md) values of documents. You can use two types of path values:

- Exact paths of individual documents
- Expressions containing special characters that specify multiple documents or relative paths

You need to use path expressions in the **Path** property of [web parts](https://docs.kentico.com/k8/developing-websites/developing-websites-using-the-portal-engine/using-and-configuring-web-parts.md) or controls that load data from documents (document data sources, document listings with built-in data sources, [navigation components](https://docs.kentico.com/k8/developing-websites/loading-and-displaying-data-on-websites/building-website-navigation.md)).

## Using wildcard characters (% and \_)

The **% wildcard represents any number of characters**.Add the wildcard to the end of the path to select all documents under the specified section of the site.

Examples:

- **/** - only the root document
- **/%** - all documents
- **/Products** - only the _Products_ document
- **/Products/%** - all child documents under the _Products_ document

The \_ **wildcard represents a single character**. For example:

- **/Product\_** - selects documents _/ProductA_, _/Product1_, etc.

> **Tip:** **Escaping wildcards in paths**
>
> If you need to use the wildcards as standard characters inside path expressions, enclose the character inside brackets (\[ ]). For example:
>
> - **/Special\[\_]Offers -** selects the _Special\_Offers_ document

## Using relative paths

You can use relative paths expressions to **select child documents or parent documents**.

Examples:

- **.** - the current document's path
- **..** - the path of the current document's parent
- **./Product** - document _Product_ under the current path
- **../Product** - document _Product_ under the parent document of the current path
- **./%** - all documents under the current path (or selection of the current document, see _Leaving the Path value empty_ below)
- **../%** - all documents under the parent document of the current path

## Leaving the Path value empty

If you leave the path value empty, the behavior depends on the type of the component and other variables.

#### Navigation components

For [navigation components](https://docs.kentico.com/k8/developing-websites/loading-and-displaying-data-on-websites/building-website-navigation.md) (such as the **CSS list menu** web part), an empty value always sets the path to all documents (equivalent of /%).

#### Standard document data sources

General web parts and controls with document data sources perform one of the following actions if you leave the Path property empty:

- **Selection of the current document** - the component loads and displays only the current document using the _Selected item_ [transformation](https://docs.kentico.com/k8/developing-websites/loading-and-displaying-data-on-websites/writing-transformations.md) (if specified).
- **Loading of child documents** - equivalent of _/%_. All [filtering options](https://docs.kentico.com/k8/developing-websites/loading-and-displaying-data-on-websites/loading-document-data.md) specified for the data source still apply.

The behavior depends on the following conditions:

\* Whether the listing component's **Document types (ClassNames)** property includes the current document's [document type](https://docs.kentico.com/k8/developing-websites/defining-website-data-structure/document-types.md). **Note**: An empty value includes all document types.\
\*\* If the current document type has the **Behaves as Page (menu item) type** flag enabled (_Document types -> Edit the document type -> General_).

| Document type match (\*) | Behaves as Page (menu item) type flag (\*\*) | Empty path behavior                           |
| ------------------------ | -------------------------------------------- | --------------------------------------------- |
|                          |                                              | Selection of the current document             |
|                          |                                              | Loading of child documents                    |
|                          |                                              | Loading of child documents                    |
|                          |                                              | The data source does not load any data at all |

> **Note:** For standard document data sources, the **./%** path expression works exactly the same way as an empty path value.

## Getting parts of the current path

You can use special expressions to **extract parts of the current document's path**.

- {0} - the alias of the document on the first level of the current path
- {1} - the document alias of the current path's second level
- ...

For example, if the document path is: _**/Company/Careers/USA-Branch/Development/QA-Engineer**_

- **{0}** = Company
- **{1}** = Careers
- **{3}** = Development

Path examples:

- **/{0}/{1}/%** - all documents under the second level of the current path
- **/{0}/{1}/Details** - document _Details_ on the third level of the current path

> **Note:** **Note**: If you attempt to extract a level that does not exist in the current document's path:
>
> - The expression returns an empty value.
> - If there is a slash (/) after the expression, the system removes it when resolving the overall path.
