---
title: "Route Definitions · Unlighthouse"
meta:
  "og:description": "Configure route discovery and custom sampling patterns for better page organization and intelligent scanning."
  "og:title": "Route Definitions · Unlighthouse"
  description: "Configure route discovery and custom sampling patterns for better page organization and intelligent scanning."
---

**Guides**

# **Route Definitions**

[Copy for LLMs](https://unlighthouse.dev/guide/guides/route-definitions.md)

Map URLs to source files for intelligent [**dynamic sampling**](https://unlighthouse.dev/guide/guides/dynamic-sampling). Framework integrations discover routes automatically; CLI users may need manual configuration for optimal sampling.

## [Pages directory](#pages-directory)

By default, the `pages/` dir is scanned for files with extensions `.vue` and `.md`, from the `root` directory.

If your project has a different setup you can modify the configuration.

```
import { defineUnlighthouseConfig } from 'unlighthouse/config'

export default defineUnlighthouseConfig({
  root: './app',
  discovery: {
    pagesDir: 'routes',
    fileExtensions: ['jsx', 'md'],
  },
})
```

## [Custom sampling](#custom-sampling)

When you have URL patterns which don't use URL segments or the mapping is failing, it can be useful to map the sampling yourself.

By using the `customSampling` option you map regex to a route definition.

In the below example we will map any URL such as `/q-search-query`, `/q-where-is-the-thing` to a single route definition, which allows the sampling to work.

```
export default defineUnlighthouseConfig({
  scanner: {
    customSampling: {
      '/q-(.*?)': {
        name: 'search-query',
      },
    },
  },
})
```

[Edit this page](https://github.com/harlan-zw/unlighthouse/edit/main/docs/1.guide/guides/route-definitions.md)

[Markdown For LLMs](https://unlighthouse.dev/guide/guides/route-definitions.md)

**Did this page help you? **

Anything that could be done better? :)

Help us improve this page. You can [edit this page](https://github.com/harlan-zw/unlighthouse/edit/main/docs/1.guide/guides/route-definitions.md) on GitHub or provide anonymous feedback below.

[**Puppeteer** Configure Puppeteer launch options for headless Chrome: --no-sandbox, Docker args, viewport, executable path, and navigation hooks. Copy-paste configs for CI and Docker.](https://unlighthouse.dev/guide/guides/puppeteer) [**URL Discovery** How Unlighthouse discovers pages using sitemaps, robots.txt, and internal link crawling. Configure URL sources and filters.](https://unlighthouse.dev/guide/guides/url-discovery)

**On this page **

- [Pages directory](#pages-directory)
- [Custom sampling](#custom-sampling)