---
title: "How to build a job directory and search page"
label: "Job directory and search"
description: "Combine context, filters, numbered or cursor pagination, job cards, and canonical URLs."
publishedAt: 2026-07-10
updatedAt: 2026-10-06
order: 0
status: "published"
---

A listing page should be driven by URL state so search engines and users can share the same result set.

## Parse public URL state

Use the SDK’s filter vocabulary instead of accepting arbitrary values. Invalid public query parameters are dropped rather than throwing.

```ts
// src/lib/load-jobs.ts
import { parseListingFilters } from '@cavuno/board/filters';

import { board } from './cavuno';

export async function loadJobs(search: Record<string, unknown>) {
  const filters = parseListingFilters(search);
  const common = {
    remoteOption: filters.remoteOption ? [filters.remoteOption] : undefined,
    employmentType: filters.employmentType
      ? [filters.employmentType]
      : undefined,
    seniority: filters.seniority,
  };

  if (filters.q) {
    return board.jobs.search({
      query: filters.q,
      sort: filters.sort,
      filters: common,
      limit: 20,
    });
  }

  return board.jobs.list({
    ...common,
    sort: filters.sort,
    limit: 20,
  });
}
```

Browse uses `GET board.jobs.list`; free-text search uses `POST board.jobs.search`. Both return job cards with `data`, `hasMore`, and `nextCursor`. Catalog responses can also include `count`, `limit`, `offset`, and `gatedCount`.

To filter by the board's own job or company custom fields, such as an opportunity type or an employer type, follow [Custom field filters and badges](/docs/sdk/cookbook/custom-field-filters-and-badges).

## Format cards in the board language

Load `board.context()` once for the board language. Pass that language into every label-producing helper.

```ts
import {
  formatPublishedRelativeDate,
  formatSalaryRange,
} from '@cavuno/board/format';

const context = await board.context();
const page = await loadJobs(searchParams);

const cards = page.data.map((job) => ({
  ...job,
  location: job.locationLabel,
  published: formatPublishedRelativeDate(
    context.language,
    job.publishedAt,
  ),
  salary: formatSalaryRange(
    context.language,
    job.salaryMin,
    job.salaryMax,
    job.salaryTimeframe,
    job.salaryCurrency,
  ), // { text, timeframe, bound } | null — map enum + bound chrome app-side
}));
```

## Filter and badge by custom fields

Job custom fields can drive both listing filters and card badges. The definitions come from `board.context().customFields.job`: use each option's `label` as the control text and keep the option `key` in the URL (`/jobs?work_type=contract`), because labels change when the operator renames an option and keys do not. Send the selected keys as `filters.customFields` on `board.jobs.search`, and drop any URL value that is not a current option so it never reaches the API.

```ts
const context = await board.context();
const workType = context.customFields.job.find(
  (field) => field.key === 'work_type',
);
const selected = searchParams
  .getAll('work_type')
  .filter((key) => workType?.options?.some((option) => option.key === key));

const results = await board.jobs.search({
  query: filters.q,
  filters: {
    customFields:
      selected.length > 0 ? [{ key: 'work_type', values: selected }] : undefined,
  },
  limit: 20,
});
```

Every job card carries `customFieldValues` for the job and `company.customFieldValues` for its company, so a badge needs no extra request per job. Only single-select, multi-select, yes/no and number values appear on cards; text fields stay on the full job and company, and private company fields never appear. Select values are option keys, so resolve them to labels before rendering. For job values, `resolveCustomFieldDisplay` does this against the job definitions:

```ts
import { resolveCustomFieldDisplay } from '@cavuno/board/format';

const badges = resolveCustomFieldDisplay(
  context.language,
  context.customFields.job.filter((field) => field.key === 'work_type'),
  card.customFieldValues,
);

// Company values resolve against the public company definitions.
const companyFields = await board.profileFields.retrieve('company');
const tier = companyFields.definitions.find((f) => f.key === 'member_tier');
const tierKey = card.company?.customFieldValues.member_tier;
const tierBadge = tier?.options?.find((o) => o.key === tierKey)?.label ?? null;
```

Load both sets of definitions once per page, not once per card. Drop a value whose key or option has no current definition rather than printing the raw key.

## Build the page head from the same result

Do not calculate metadata from different filters or a separate result set. The visible heading, result count, canonical path, and structured data should describe the same page.

```ts
import { listingHead, listingJsonLd } from '@cavuno/board/seo';

const origin = 'https://jobs.example.com';
const path = pageNumber > 1 ? `/jobs?page=${pageNumber}` : '/jobs';
const heading = 'Remote jobs';
const countLabel = new Intl.NumberFormat(context.language).format(page.count);
// Application owns title/description composition (counters, order, separators).
const title = messages.listingTitle({
  count: page.count,
  countLabel,
  heading,
  boardName: context.name,
});
const description = messages.listingDescription({
  count: page.count,
  countLabel,
  heading,
  boardName: context.name,
});

const head = listingHead({
  title,
  origin,
  path,
  description,
});

const jsonLd = listingJsonLd({
  origin,
  breadcrumbs: [
    { name: 'Home', path: '/' },
    { name: heading },
  ],
  jobs: page.data,
});
```

Map `head.meta` and `head.links` into the framework’s metadata API. Serialize each JSON-LD object safely into an `application/ld+json` script.

## Use numbered pages for direct navigation

Most public directories should expose stable page URLs:

```ts
const pageNumber = Math.max(1, Number(searchParams.page ?? '1'));
const limit = 20;

const page = await board.jobs.list({
  ...filters,
  limit,
  offset: (pageNumber - 1) * limit,
});
```

Preserve every active filter when generating `?page=2`. Reset the page to 1 when the visitor changes a filter. Use the response’s `hasMore`, `count`, and `gatedCount` when present; do not fabricate a total.

Give each numbered page its own self-referencing canonical: `/jobs` for page 1 and `/jobs?page=2` for page 2. Do not canonicalize the whole sequence to page 1. Render previous and next navigation as real `<a href>` links so crawlers and keyboard users can follow the sequence; a button-only “Load more” control is not a crawl path. See Google’s [pagination guidance](https://developers.google.com/search/docs/specialty/ecommerce/pagination-and-incremental-page-loading).

Treat arbitrary search, sort, and filter combinations as discovery states. They should normally use `noindex,follow`, while the unfiltered directory and each numbered page remain indexable. Index a filtered route only when you have deliberately created a stable landing page with a canonical path, unique useful content, internal links, and enough matching jobs.

## Add a search distance to city pages

A city page such as `/jobs/locations/houston-tx-united-states` reads better when it also lists jobs a short commute away: "Showing 1–20 jobs within **25 mi** ⌄ of Houston". The jobs API has no default distance, so your page decides it and passes `radius` in kilometres.

```ts
import {
  defaultSearchRadius,
  distanceUnitForCountry,
  formatDistance,
  searchRadiusOptions,
} from '@cavuno/board/format';

const place = await board.taxonomy.places.resolve(placeSlug);
const geo = place.geo;
const canWiden =
  (geo?.placeType === 'city' || geo?.placeType === 'locality') &&
  geo.lat !== null &&
  geo.lng !== null;

const unit = distanceUnitForCountry(geo?.countryCode);
const options = searchRadiusOptions(unit); // 5, 10, 25, 50, 100 in mi or km
const fallback = defaultSearchRadius(unit); // 25 mi or 50 km

// ?within=0 is exact location only; any other value must be a preset.
const within = searchParams.within;
const selected =
  within === '0'
    ? null
    : (options.find((option) => String(option.value) === within) ?? fallback);

const page = await board.jobs.list({
  location: place.sourceSlug,
  radius: canWiden && selected ? selected.km : undefined,
  limit: 20,
});

const distanceLabel = selected
  ? formatDistance(selected.value, selected.unit, board.language)
  : null; // "25 mi"
```

Follow the same rules as hosted boards so search engines see one page per place:

- Show the menu only when `canWiden` is true. Region and country pages, and places without coordinates, list jobs in the place and ignore `within`.
- Offer "Exact location only" (`within=0`) and the five presets. When the visitor picks the default, drop `within` so the plain URL stays the default view. Treat an unknown `within` value as the default.
- Keep `within` when the visitor pages through results or changes a filter on the same place.
- Index only the plain URL. Any URL with a valid `within` value gets `noindex, follow` and a canonical that points at the plain URL.
- Mark a city page `noindex, follow` when the place has no jobs of its own, even at the default distance, so it does not rank on a neighbor's jobs. Read the place's own count from `jobCount` in [`board.taxonomy.places.list`](/docs/sdk/reference/taxonomy#boardtaxonomyplaceslist), not from the widened `page.count`.
- Leave sitemaps on in-place counts; distance views never appear there.

See [Styling and formatting](/docs/sdk/frontend-infrastructure/formatting#format-distances) for the distance helpers.

## Use cursors for load-more and traversal

Echo `nextCursor` into the next request while preserving the filters. If the first request uses `offset`, drop it before following a cursor—`paginate()` does this automatically.

```ts
import { paginate } from '@cavuno/board';

for await (const job of paginate(board.jobs.list, { limit: 100 })) {
  console.log(job.links.public);
}
```

For load-more interfaces, echo `nextCursor` unchanged. For a background walk, use `paginate`. Do not translate a cursor into a page number or combine it with a non-zero offset.

## Offer weekly alerts without requiring an account

When job alerts are enabled in `board.context().features`, let a visitor subscribe from the current search state. Anonymous subscriptions require affirmative consent and use double opt-in.

```ts no-check
await board.jobAlerts.subscribe({
  email,
  consent: true,
  frequency: 'weekly',
  filters: {
    jobFunctions: selectedJobFunctions,
    placeSlugs: selectedPlaceSlugs,
    remoteOptions: selectedRemoteOptions,
  },
  context: { source: 'job-search' },
});
```

The confirmation link supplies the token for `board.jobAlerts.confirm({ token })`. Do not imply that the alert is active before confirmation. Digest links should lead to the token-authenticated manage experience where the subscriber can update, unsubscribe, or delete the preference. Weekly is the only supported frequency.

## Verify the page

1. Copy a filtered URL into a new browser and confirm it renders the same selection.
2. Test no results, invalid filters, a gated count, and a failed search dependency.
3. Open page 1 and page 2 directly, then follow a cursor from the same filtered result; confirm neither path repeats an item because an old offset remained.
4. Inspect the canonical and `ItemList` URLs against the visible cards.
5. Navigate the pagination using only a keyboard and confirm a crawler can discover page 2 from an anchor `href` in the initial HTML.
6. Subscribe anonymously, confirm through the emailed token, and verify that manage and unsubscribe actions work without creating an account.
7. Open a city page and confirm the default distance (25 mi or 50 km) is applied with no `within` in the URL. Pick "Exact location only" and a preset, and confirm both URLs are `noindex, follow` with the plain URL as canonical. Open a region page and confirm it shows no distance menu.

## Production notes

- Show gated counts honestly when a paywall limits results.
- Abort superseded interactive searches.
- Keep filters within the Board API’s supported vocabulary.
- Use an explicit sort when stable iteration matters; the default relevance ranking can change as jobs or featured status change.
- Give the result count or loading region a polite status announcement, preserve focus when filters update, and keep every filter paired with a visible label.

See the [Jobs reference](/docs/sdk/reference/jobs) for the complete query and response contract.
