On the site levellegal.com, when you search for certain words or phrases, one of the URL's in the search results will be the search results itself. A good example is to search for "antitrust". The first result is correct, the second result is the anomaly. Otherwise the search works fine. We didn't build the site, so not real familiar with it.

2 Answers 2


Without access to the code, it's hard to tell you where the error lies. There are multiple ways to build a search functionality both using built-in Craft functionality, custom code or external services. If your site is using the regular craft search functionality, you could probably fix this by adjusting which sections can be found using the .section query parameter. If your search is custom-built, you will need to either modify your search parameters so the search page itself can't be found, or – if your search uses a custom index – make sure the search results page can't end up in the index itself.



If you look at the source of your search result page, you'll notice that the search result that points to the search result page (at the time of writing, the second antitrust link) has in fact an empty URL.

Snippet of the source of the search result page:

    <li><a href="https://www.levellegal.com/what-we-do/antitrust">Antitrust</a></li>
    <li><a href="">Antitrust</a></li>
    <li><a href="https://www.levellegal.com/what-we-do/for-compliance-counsel">Compliance</a></li>
    <li><a href="https://www.levellegal.com/news/managing-antitrust-reviews-that-span-multiple-jurisdictions">Managing antitrust reviews that span multiple jurisdictions</a></li>
    <li><a href="https://www.levellegal.com/news/navigating-second-requests-in-cross-border-antitrust-merger-reviews">Navigating Second Requests in Cross-Border Antitrust Merger Reviews</a></li>
    <li><a href="https://www.levellegal.com/who-we-are/our-people/sarah-young">Sarah Young, JD</a></li>
    <li><a href="https://www.levellegal.com/who-we-are/our-people/jeffrey-morgan">Jeffrey Morgan, JD</a></li>
    <li><a href="https://www.levellegal.com/who-we-are/our-people/albert-azagra-malo">Albert Azagra-Malo, LLB, LLM, JSD (PhD in Law)</a></li>
    <li><a href="https://www.levellegal.com/">Home</a></li>
    <li><a href="https://www.levellegal.com/news/how-alsps-stack-up-against-the-big-4">​How ALSPs stack up against the Big 4</a></li>


You can try adding the following to your search query: .uri('not :empty:'). It will filter out entries from sections that don't have a URL.


{% set searchTerm = craft.app.request.getParam('q') %}
{% set searchResults = craft.entries.search(searchTerm).uri('not :empty:').orderBy('score') %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.