How to Build a Searchable Directory on Wix with Velo and Dynamic Pages
Usama MehmoodCo-owner & CEO · 11 min readTo build a searchable Wix directory website, store your listings in a CMS collection, give every listing its own dynamic page, and show the listings on a directory page in a repeater driven by Velo code. A search box and dropdown filters build a wix-data query, a "Load more" button pages through the results, and empty states handle searches with no matches. The dynamic pages carry the SEO weight, so each one gets a proper title, description and structured data. This tutorial builds the whole thing with complete code.
Key takeaways
- Two collections cover most directories:
ListingsandCategories, linked by a reference field, plus aslugfor clean URLs and apublishedflag for drafts.- Keep a lowercase
searchTextfield filled by a data hook. Onecontains()on one field is more predictable than chainingor()queries with filters.- Debounce the search input, ignore out-of-date responses, and page with
hasNext()andnext()instead of loading everything.- Search results are for visitors; listing and category pages are what Google indexes. Put your SEO effort there.
- Drive a repeater with code or with a dataset, never both.
If you have never written Velo code, start with our Wix Velo tutorial for beginners. It covers Dev Mode, $w, repeaters and web modules, which this post uses without re-explaining.
What we are building
| Piece | What it does | Built with |
|---|---|---|
| Directory page | Search, category and city filters, result count, load more | Repeater + page code |
| Listing pages | One page per listing at /listings/{slug} |
Dynamic item page |
| Category pages | One page per category at /categories/{slug}, listing its businesses |
Dynamic page + filtered repeater |
| Search field | Fast, simple text search | Data hook in backend/data.js |
| SEO | Titles, descriptions, structured data | Dynamic page SEO settings + wix-seo-frontend |
The same structure fits member directories, supplier lists and job boards. We've built directories on several platforms, including the portfolio-company directory on the Lightspeed Venture Partners site (WordPress); the data design questions never change.
Step 1: Design the CMS collections
Getting the collections right is most of the work.
Categories: title (Text), slug (Text), description (Text).
Listings:
| Field key | Type | Notes |
|---|---|---|
title |
Text | Business or listing name |
slug |
Text | URL-safe and unique, e.g. acme-plumbing-austin |
summary |
Text | One or two sentences for cards and meta descriptions |
description |
Rich text | Full listing page content |
category |
Reference → Categories | Single reference |
city |
Text | Used as a filter |
tags |
Tags | Extra search terms |
logo |
Image | |
phone, website |
Text / URL | |
published |
Boolean | Lets you keep drafts in the collection |
searchText |
Text | Filled automatically, never edited by hand |
Three decisions worth explaining:
- Category is a reference, city is text. Categories need their own pages and descriptions, so they get a collection. Cities are usually just a filter value; if they need landing pages too, give them a collection.
- The
slugfield is yours, so you can build links in code without relying on generated field keys. - Permissions: both collections readable by Anyone, with create, update and delete set to Admin. If visitors submit listings, send submissions to a separate collection through a backend web module and approve them before they reach
Listings. Never open write access on the collection the public directory reads from.
Step 2: Fill the search field with a data hook
Searching title, summary, city and tags means either several or() queries or one combined field. or() gets confusing once you add filters, because it applies to everything defined before it. A single field avoids the problem.
Create backend/data.js (Wix looks for hooks in that file) and add:
// backend/data.js
// Hook names use the collection ID: Listings_beforeInsert, Listings_beforeUpdate
function slugify(text) {
return String(text || '')
.toLowerCase()
.trim()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '');
}
function prepareListing(item) {
if (!item.slug && item.title) {
item.slug = slugify(item.title);
}
item.searchText = [item.title, item.summary, item.city, ...(item.tags || [])]
.filter(Boolean)
.join(' ')
.toLowerCase();
return item;
}
export function Listings_beforeInsert(item, context) {
return prepareListing(item);
}
export function Listings_beforeUpdate(item, context) {
return prepareListing(item);
}
The hooks run on every insert and update, whether from code, a dataset, the CMS or an import. Listings that existed before the hook need saving once to get searchText, and generated slugs aren't guaranteed unique, so check for duplicates.
Step 3: Create the dynamic pages
In the editor's CMS panel, add:
- A Listings item page with the URL pattern
/listings/{slug}. Design one listing layout and connect its elements to the dynamic dataset Wix adds to the page. Add a dataset filter forpublishedis true so drafts don't render. - A Categories item page at
/categories/{slug}. This works as the category list page: add a repeater connected to a second dataset onListings, filtered to the current category and to published items.
Datasets handle these pages with no code. The code goes on the directory page, where filtering is too dynamic for dataset settings.
Step 4: Build the directory page
Add a regular page called Directory with these elements, renaming each ID in Properties & Events:
searchInput(text input) andcategoryDropdown,cityDropdown(dropdowns with no options set)resultCount(text) andloadingText(text "Searching…", collapsed on load)listingsRepeater; inside each item:listingLogo(image),listingName,listingCategory,listingCity,listingSummary(text) andviewButton(button)loadMoreButton(collapsed on load)emptyState, a box collapsed on load, holding a "No listings match your search" text and aclearFiltersButtonerrorText(collapsed on load)
Don't connect the repeater to a dataset. The code owns it.
Step 5: The directory page code
Paste this into the Directory page's code file:
// Directory page code
import wixData from 'wix-data';
const COLLECTION = 'Listings';
const PAGE_SIZE = 12;
const ALL = 'all';
let currentResults = null; // last WixDataQueryResult, used by "Load more"
let requestId = 0; // lets us ignore responses from out-of-date searches
let debounceTimer;
$w.onReady(async () => {
// Register onItemReady BEFORE setting repeater data
$w('#listingsRepeater').onItemReady(($item, itemData) => {
$item('#listingName').text = itemData.title;
$item('#listingCategory').text = itemData.category?.title || '';
$item('#listingCity').text = itemData.city || '';
$item('#listingSummary').text = itemData.summary || '';
if (itemData.logo) {
$item('#listingLogo').src = itemData.logo;
}
$item('#viewButton').link = `/listings/${itemData.slug}`;
});
await loadFilterOptions();
await search();
$w('#searchInput').onInput(() => {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(search, 350);
});
$w('#categoryDropdown').onChange(() => search());
$w('#cityDropdown').onChange(() => search());
$w('#loadMoreButton').onClick(loadMore);
$w('#clearFiltersButton').onClick(() => {
$w('#searchInput').value = '';
$w('#categoryDropdown').value = ALL;
$w('#cityDropdown').value = ALL;
search();
});
});
async function loadFilterOptions() {
const [categories, cities] = await Promise.all([
wixData.query('Categories').ascending('title').limit(100).find(),
wixData.query(COLLECTION).eq('published', true).distinct('city'),
]);
$w('#categoryDropdown').options = [
{ label: 'All categories', value: ALL },
...categories.items.map((c) => ({ label: c.title, value: c._id })),
];
$w('#cityDropdown').options = [
{ label: 'All cities', value: ALL },
...cities.items.filter(Boolean).sort().map((city) => ({ label: city, value: city })),
];
$w('#categoryDropdown').value = ALL;
$w('#cityDropdown').value = ALL;
}
function buildQuery() {
const term = $w('#searchInput').value.trim().toLowerCase();
const category = $w('#categoryDropdown').value;
const city = $w('#cityDropdown').value;
let query = wixData.query(COLLECTION).eq('published', true);
if (term.length >= 2) query = query.contains('searchText', term);
if (category && category !== ALL) query = query.eq('category', category);
if (city && city !== ALL) query = query.eq('city', city);
return query.include('category').ascending('title').limit(PAGE_SIZE);
}
async function search() {
const thisRequest = ++requestId;
toggle('#loadingText', true);
try {
const results = await buildQuery().find();
if (thisRequest !== requestId) return; // a newer search has started
currentResults = results;
$w('#listingsRepeater').data = results.items;
render(results);
} catch (err) {
if (thisRequest !== requestId) return;
console.error('Directory search failed', err);
$w('#errorText').text = 'Something went wrong loading the directory. Please refresh the page.';
showOnly('#errorText');
} finally {
if (thisRequest === requestId) toggle('#loadingText', false);
}
}
async function loadMore() {
if (!currentResults || !currentResults.hasNext()) return;
const thisRequest = requestId;
$w('#loadMoreButton').disable();
try {
const nextPage = await currentResults.next();
if (thisRequest !== requestId) return; // filters changed while loading
currentResults = nextPage;
$w('#listingsRepeater').data = [...$w('#listingsRepeater').data, ...nextPage.items];
render(nextPage);
} catch (err) {
console.error('Load more failed', err);
} finally {
$w('#loadMoreButton').enable();
}
}
function render(results) {
if (results.totalCount === 0) {
$w('#resultCount').text = '0 listings';
showOnly('#emptyState');
return;
}
showOnly('#listingsRepeater');
const shown = $w('#listingsRepeater').data.length;
$w('#resultCount').text = `Showing ${shown} of ${results.totalCount} listings`;
toggle('#loadMoreButton', results.hasNext());
}
function showOnly(selector) {
['#listingsRepeater', '#emptyState', '#errorText'].forEach((id) => toggle(id, id === selector));
if (selector !== '#listingsRepeater') toggle('#loadMoreButton', false);
}
function toggle(selector, visible) {
if (visible) $w(selector).expand();
else $w(selector).collapse();
}
What each part does
One query builder. buildQuery() starts from published listings and adds a condition only for filters the visitor set. Every condition is an AND, so there are no surprises about which filter applies where. contains() is case-insensitive, and eq() is the recommended way to match a reference field. include('category') pulls the category item into each result so the card can show its name without a second query.
Debounce plus a request counter. The 350 ms debounce stops a query on every keystroke and keeps you inside Wix's data request quotas. The requestId check means a slow response for "plu" arriving after the one for "plumb" is ignored instead of overwriting the right results.
Paging with next(). Each query fetches 12 items. hasNext() decides whether the button shows, next() fetches the following page of the same query, and totalCount drives the "Showing 12 of 87" text. limit() accepts up to 1,000, but big pages slow the first paint; 12 to 24 cards is a good range.
Empty and error states. No matches shows a message and a clear-filters button; a failed query shows an error instead of failing silently.
Dropdowns from data. Categories come from their collection; cities come from distinct('city'), so new cities appear automatically. distinct() results are paged like find() results, so with more than a few dozen cities, move them into a collection of their own.
Prefer a dataset? The equivalent is $w('#listingsDataset').setFilter(wixData.filter().eq('published', true).contains('searchText', term)). Fine for simple directories, but never connect a dataset and also assign repeater.data on the same repeater.
Step 6: SEO for dynamic pages
Search engines mostly see the directory page's first load. The pages that rank are listing and category pages, because each has its own URL and content.
Titles and descriptions from fields
In the listing page's SEO settings, build the title tag from dynamic values (for example "{Title} in {City} | Your Directory") and use summary as the meta description. Do the same for category pages. It is configuration, not code, and it is the most important SEO step for a Wix directory website.
Structured data and related listings
On the Listings item page, add LocalBusiness structured data:
// Listings (Item) dynamic page code
import wixSeoFrontend from 'wix-seo-frontend';
$w.onReady(async () => {
await new Promise((resolve) => $w('#dynamicDataset').onReady(resolve));
const listing = $w('#dynamicDataset').getCurrentItem();
if (!listing) return;
await wixSeoFrontend.setStructuredData([
{
'@context': 'https://schema.org',
'@type': 'LocalBusiness',
name: listing.title,
description: listing.summary,
telephone: listing.phone,
url: listing.website,
address: { '@type': 'PostalAddress', addressLocality: listing.city },
},
]);
});
Wix's documentation says to set SEO data inside onReady() so search engines can read it, which is why the handler waits for the dataset before setting it. setStructuredData() replaces structured data set earlier on the page, so test a few listing URLs in Google's Rich Results Test after publishing.
For related listings, a second dataset on the item page filtered to the same category, connected to a small repeater, does the job with no code.
The rest of the checklist
- Internal links: directory page → category pages → listings, and each listing back to its category and to related listings. This is how search engines find deep listings.
- Thin pages: require a real summary and description before setting
publishedto true. - Indexing: dynamic pages appear in Wix's sitemap. Check Search Console after launch and fix listings flagged as duplicates, usually near-identical descriptions.
For the bigger picture, see Is Wix good for SEO? or our Wix SEO service.
Performance and limits
- CMS item limits depend on your plan. Check Wix's current plan comparison before importing thousands of listings.
- Data from another system? Sync it into the CMS with a scheduled job rather than calling an API on every search. Our guide to connecting Wix to an external API with Velo covers the backend side, including keeping API keys in the Secrets Manager.
- Test on live data: Preview may use sandbox collections, so test search on a published test site.
- Beyond search: map views, paid featured listings and member submissions need more backend work; that is the kind of feature our Wix Velo developers build.
How Wix Engine can help
Directories grow complicated fast: submissions with approval, paid featured listings, map views, reviews and SEO across thousands of dynamic pages. As a Wix Legend Partner with 2,000+ projects since 2014, we build them on Wix Studio with clean, documented Velo code your team can maintain. Custom Velo features start from $500; see our Wix Velo development services.
FAQ
Can you build a directory website on Wix?
Yes. A Wix directory website uses a CMS collection for listings, dynamic pages for listing and category pages, and Velo code for search and filters. It works on Wix Studio and the Classic Editor, and handles directories from dozens to thousands of listings within your plan's CMS item limits.
Do I need code to filter a repeater on Wix?
Not for simple cases: a repeater connected to a dataset can be filtered by inputs with no code. For a search box combined with several dropdowns, result counts and load more, Velo code with wix-data queries is more reliable and easier to control.
How do I make Wix dynamic pages SEO-friendly?
Use a clean URL pattern such as /listings/{slug}, build the title tag and meta description from collection fields in the dynamic page's SEO settings, require real content on every item, and add structured data with wix-seo-frontend. Link listings from category pages so search engines can reach every item.
Why does my Wix search show old results when I type fast?
Responses can arrive out of order, so a slow query for an earlier search overwrites the newer results. Debounce the input and keep a request counter, ignoring any response that doesn't belong to the latest request, as the code above does.
How many items can a Wix CMS collection hold?
It depends on your Wix plan, and Wix revises the limits periodically, so check the current plan comparison before a large import. A single wix-data query returns at most 1,000 items per page, which is why directories page through results instead of loading everything at once.

Usama Mehmood
Co-owner & CEO at Wix Engine
Wix Certified designer and developer, senior software and AI engineer with 15 years of experience. Started Wix Engine in 2014.
LinkedIn ↗Keep reading
Velo TutorialsHow to Connect Wix to Any External API with Velo
Wix Velo fetch API tutorial: call any REST API from a backend web module with wix-fetch, keep keys in the Secrets Manager, and show the result on a page.
· 9 min read
Velo TutorialsWix Velo Tutorial for Beginners: Build Your First Custom Feature
A Wix Velo tutorial: enable Dev Mode, write your first page code, build a live search over the CMS, and add a secure backend form in one afternoon.
· 10 min read
WixWhat Is a Wix Legend Partner (and Why It Matters When You Hire)?
What a Wix Legend Partner is, how Wix Partner levels and Wix Studio certifications are earned, what the badges miss, and how to verify a partner.
· 9 min read
Want an expert to look at your project?
Book a free 30-minute call with the Wix Engine team. You'll get honest advice and a detailed proposal within 24 hours.