> For the complete documentation index, see [llms.txt](https://docs.nosto.com/techdocs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nosto.com/techdocs/implementing-nosto/implement-search/using-search-templates-starter/customizations/url-mapping.md).

# URL Mapping

### Search Results Page URL Management

When a search is performed (either by submitting the search form or clicking a non-redirect keyword), the user is taken to the search results page. The state of the search (query, filters, pagination, etc.) is reflected in the URL's query parameters.

#### URL Structure

The search results page URL is managed by a set of utility functions in `src/mapping/url/`. The URL is constructed with the following parameters:

* `q`: The search query.
* `p`: The current page number (omitted for the first page).
* `size`: The number of results per page.
* `filter.*`: Applied filters (e.g., `filter.brand=Nike`).
* `sort`: The selected sorting option.

#### How It Works

1. **State Management**: The `SearchQueryHandler` component (`src/components/SearchQueryHandler/SearchQueryHandler.tsx`) is responsible for synchronizing the application's search state with the URL.
2. **URL Updates**: It uses the `updateUrl` function (`src/mapping/url/updateUrl.ts`) to serialize the current search state into URL parameters and update the browser's history using `window.history.replaceState`.
3. **Initial State**: On page load, the `getCurrentUrlState` function (`src/mapping/url/getCurrentUrlState.ts`) deserializes the parameters from the URL to initialize the search state. This ensures that a user can share a URL, and it will load the same search results.

#### Example

A search for "shoes" on the second page with a filter for the brand "Nike" would result in a URL like this:

`/search?q=shoes&p=2&filter.brand=Nike`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.nosto.com/techdocs/implementing-nosto/implement-search/using-search-templates-starter/customizations/url-mapping.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
