Jump to content

Hide file extensions from native search

Recommended Posts

I've got a bit of a catch-22 here. Client wants to remove asset image extensions (pear.jpg etc) from appearing in dedicated search - client also does not want the assets renamed to anything other than what the item is. Is there any way I can block the text or remove the entire description from the search? I'm pulling my hair out here.


Screenshot 2023-10-02 at 3.53.36 PM.png

Link to comment
  • Replies 2
  • Views 1.2k
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

Try this code to Website Tools (under Not Linked) > Code Injection > Footer

<!-- Remove jpg in search page -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
const attrObserver = new MutationObserver((mutations) => {
  mutations.forEach((mu) => {
    if (mu.type !== "attributes" && mu.attributeName !== "class") return;

const ELS_test = document.querySelectorAll(".search-results");
ELS_test.forEach((el) => attrObserver.observe(el, { attributes: true }));

function trimEXT() {
  $(".search-results img").ready(function () {
    $(".sqs-search-page .sqs-title").html(function () {
      return $(this).html().replace(".jpg", "").replace(".png", "").replace(".jpeg", "");

$(document).ready(function () {


Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.