Content & media
Search & filters
A search box for the whole site, and lists visitors can search, narrow and sort — on a static site, with no server to ask.
Two elements under + → Search answer two questions that look like one. A Search finds something anywhere on the site; a Filter narrows the list it holds. Neither needs a server: the site ships an index and a small script, and with JavaScript off every page and every card is simply there.
Searching the site
Place a Search anywhere — usually in the header template. Typing shows the best matches under the field, and Enter goes to the results page. If the site has none, sitereal makes one at /search the moment you place the first site search, and says so: an ordinary page holding the Results page element, kept out of search engines and the sitemap. Settings → Search says which page it is.
What a Search looks like is its Style, in the Element panel: Field with icon, an Icon that expands into a field when it is clicked, Field and button, or a Plain field. Its parts are the site’s own text field and button, so a search box is never a second design for an input.
What a result looks like
A result is a row you design, the way a Loop’s first row is. Inside Results, the Result holds {result.title}, {result.excerpt} and {result.url} — with the words found marked — and can show {result.type}, {result.description}, {result.tags} and {result.image} too.
The index
The index is built with the site, at /search-index.json: every page, plus the entries of every public collection and data source with entry pages — so a post published tomorrow is found without anybody opening the app. Settings → Search decides what goes in and how it matches: which pages and collections, how much text, whether a typed word matches the start of a word or anywhere in it, forgiving typos, ignoring accents, synonyms and weights. One answer for every search box on the site. An entry’s relations are indexed by the titles of the entries they link to, among its tags, so a course is found by its instructor’s name.
Lists visitors can narrow
A Filter wraps a Loop and gives it controls. A Search inside it searches that list as somebody types, and each Facet is made from one field of the rows — checkboxes, radio buttons, buttons, a dropdown, or a range from and to over a number or a date. The options and their counts come from the data, so there is nothing to keep in step; an option that would leave nothing is disabled or hidden. A taxonomy is offered by its terms’ names, and a relation by the titles of the entries it links to, looked up when the site is built — so a renamed instructor is a renamed option at the next build. A relation to a type kept in a database is offered by its entries’ ids instead.
Sort is a select of the site’s own whose options are the orders a visitor may pick — price low to high, newest first — each an ordinary option you can rename. Result count, Clear filters and No results are there to place wherever you want them. Every choice goes into the address, so a filtered view can be linked to and survives the back button.
Everything is in the markup first. With the script blocked the list shows every card and the search box is a text field — never an empty page.