.w-dyn-item
elements with links containing /sku/
, then fetch the linked pages.To hide search result items in Webflow that both (a) have a /sku/
in their URL and (b) link to a blank page, you can use JavaScript to filter these elements after the search results load.
.w-dyn-item
for each result.<a href="...">...</a>
) to the results page./sku/
in the URL and return a blank or empty page, likely indicating a 404 or empty content result.You can add the following script to your Page Settings > Before
tag or use an Embed element on the search results page:
href
contains /sku/
.Paste this in your custom code area:
document.addEventListener("DOMContentLoaded", function () { const resultItems = document.querySelectorAll(".w-dyn-item"); resultItems.forEach(item => { const link = item.querySelector("a[href]"); if (link && link.href.includes("/sku/")) { fetch(link.href) .then(response => response.text()) .then(html => { const parser = new DOMParser(); const doc = parser.parseFromString(html, "text/html"); // Customize this selector to target actual page content const mainContent = doc.querySelector("main") || doc.body; if (!mainContent || !mainContent.textContent.trim()) { item.style.display = "none"; } }) .catch(() => { // On error (e.g. 404), hide the item item.style.display = "none"; }); } });});
doc.querySelector("main")
with a more specific selector if your main page content is elsewhere (e.g., .page-content
, .section
, etc.)./sku/
pages that have real content.To hide search results linking to blank /sku/
pages, use JavaScript to:
/sku/
This ensures cleaner, more relevant search results without broken or placeholder pages.