> For the complete Lynkow documentation index in agent-friendly format, see [llms.txt](/llms.txt).

# PagesService

**Publié le** : 2026-08-20
**Catégorie** : Services

# PagesService

Service for retrieving published pages (Site Blocks of type "page").

Accessible via `lynkow.pages`. Pages are CMS-managed, schema-driven content
blocks (e.g. "About", "Contact", legal pages). Unlike blog articles, pages
use DataSource-resolved data instead of a rich text body. Responses are
cached for 5 minutes (SHORT TTL) when a cache adapter is configured.

Access via: `lynkow.pages`

## Methods

**5** methods

### `clearCache`

```typescript
clearCache(): void
```

Invalidate every cached page response (lists, slug lookups, path
lookups, and the JSON-LD endpoint). Call after an admin mutation or
on receipt of a `page.*` webhook so the next public request bypasses
the SWR cache and re-materializes the resolved data (including
`structuredData.graph`).

Returns: `void`

```typescript
lynkow.pages.clearCache()
```

---

### `getByPath`

```typescript
getByPath(path: string, options?: BaseRequestOptions): Promise<Page>
```

Retrieves a page by its full URL path, which may include nested segments
(e.g. `/services/consulting`). Useful when you have the path from a URL
but not the slug. Returns the same full page data as `getBySlug()`.
Cached for 5 minutes per path+locale.

| Parameter | Type | Description |
| --- | --- | --- |
| `path` | `string` | The full URL path of the page (e.g. `'/services/consulting'`, `'/about'`).<br>  Must start with a forward slash. |
| `options` | `BaseRequestOptions` | Request options; use `locale` to fetch a specific localized version |


Returns: `Promise<Page>`

```typescript
// Resolve a page from the current URL
const page = await lynkow.pages.getByPath('/services/consulting')
console.log(page.name) // "Consulting"
```

---

### `getBySlug`

```typescript
getBySlug(slug: string, options?: BaseRequestOptions): Promise<Page>
```

Retrieves a single page by its slug, including fully resolved DataSource data,
SEO settings, and alternate locale versions. Cached for 5 minutes per slug+locale.

| Parameter | Type | Description |
| --- | --- | --- |
| `slug` | `string` | The unique URL slug of the page (e.g. `'about'`, `'contact'`, `'privacy-policy'`) |
| `options` | `BaseRequestOptions` | Request options; use `locale` to fetch a specific localized version |


Returns: `Promise<Page>`

```typescript
const page = await lynkow.pages.getBySlug('about')
console.log(page.data)        // Resolved DataSource content
console.log(page.seo)         // SEO metadata
console.log(page.alternates)  // Other locale versions
```

---

### `getJsonLd`

```typescript
getJsonLd(slug: string, options?: BaseRequestOptions): Promise<Record<string, unknown>>
```

Retrieves Schema.org JSON-LD structured data for a page, ready to be
embedded in a `<script type="application/ld+json">` tag for search
engine optimization. Cached for 5 minutes per slug+locale.

| Parameter | Type | Description |
| --- | --- | --- |
| `slug` | `string` | The page slug to generate JSON-LD for (e.g. `'about'`, `'contact'`) |
| `options` | `BaseRequestOptions` | Request options; use `locale` to get locale-specific structured data |


Returns: `Promise<Record<string, unknown>>`

```typescript
const jsonLd = await lynkow.pages.getJsonLd('about')
// Embed in your HTML <head>
// <script type="application/ld+json">{JSON.stringify(jsonLd)}</script>
```

---

### `list`

```typescript
list(options?: PagesListOptions): Promise<PagesListResponse>
```

Retrieves a list of all published pages on the site. Optionally
filter by tag to get a subset (e.g. legal documents). Returns page
summaries without resolved data. Cached for 5 minutes per locale+tag.

| Parameter | Type | Description |
| --- | --- | --- |
| `options` | `PagesListOptions` | Request options:<br>  - `tag` — filter pages by tag slug (e.g. `'legal'` for privacy policy, terms, etc.)<br>  - `locale` — override the client's default locale |


Returns: `Promise<PagesListResponse>`

```typescript
// List all pages
const { data } = await lynkow.pages.list()

// List only legal documents
const { data } = await lynkow.pages.list({ tag: 'legal' })
```