# Search


<div id="pagefind-search"></div>

<link rel="stylesheet" href="/pagefind/pagefind-ui.css">
<script src="/pagefind/pagefind-ui.js"></script>
<script>
  window.addEventListener('DOMContentLoaded', () => {
    if (typeof PagefindUI === 'undefined') {
      document.getElementById('pagefind-search').innerHTML =
        '<p><em>Search is not available in the local preview: the index is generated only when the site is published (see README).</em></p>';
      return;
    }
    new PagefindUI({
      element: "#pagefind-search",
      showSubResults: true,
      showImages: false,
      resetStyles: false,
      translations: {
        placeholder: "Search the site…",
        clear_search: "Clear",
        load_more: "Load more",
        search_label: "Search",
        filters_label: "Filters",
        zero_results: "No results for [SEARCH_TERM]",
        many_results: "[COUNT] results for [SEARCH_TERM]",
        one_result: "[COUNT] result for [SEARCH_TERM]",
        alt_search: "No results for [SEARCH_TERM]. Showing results for [DIFFERENT_TERM] instead",
        search_suggestion: "No results for [SEARCH_TERM]. Try one of these searches: [SEARCH_TERMS]",
        searching: "Searching for [SEARCH_TERM]…"
      }
    });
    // Pre-fill the search from ?q=... (e.g. /en/search/?q=anarchy)
    const q = new URLSearchParams(window.location.search).get('q');
    if (q) {
      const input = document.querySelector('#pagefind-search input');
      if (input) { input.value = q; input.dispatchEvent(new Event('input')); }
    }
  });
</script>

