Exclude an article from user search, exclude category/section from tiles | Community
Skip to main content

Exclude an article from user search, exclude category/section from tiles

  • May 1, 2019
  • 4 replies
  • 0 views

I have really tried to figure this out, but would like some 2019 guidance (closest posts I can find are all years old).

I have some articles that my team wants in the Knowledge Base that will only apply to customers ONCE in their time with my company (during "launch"). Currently, we pass around pdfs which leads to confusion about which document is which version etc. Hosting these articles in the KB would simplify maintaining and providing these documents to customers.

However, I would like to avoid having these documents bog down search results and crowd the navigation of the category tiles as customers will only need the articles once in their account lifetime.

Restricting to signed-in users or org tags doesn't resolve this issue. The customer may need to share the link with internal teams (IT, Design, etc.) and then we'd have to deal with getting all those people getting registered for the KB so they can use it one time (which the internal teams tend to fight tooth and nail). Also, search results will still be bogged down for that customer.

The only solution I can find seems to be a super hacky Javascript .hide command (have to post it three times, for each article, by title... even though title can change more easily than the article ID?).

Is there a way to hide articles from the help center user search (or categories/sections from visibility) that is less hacky and not as easy to break?

Previous posts that I can find on this:

---

https://support.zendesk.com/hc/en-us/articles/230033667-Can-I-exclude-an-article-from-search-results- 

JavaScript/jQuery solution seems hacky - "I had to run the .hide() function three times to hide the title, author, and details, respectively."

---

https://support.zendesk.com/hc/en-us/community/posts/203118273-Exclude-community-posts-from-user-search-results

Best answer links to a FR that has been removed:

https://support.zendesk.com/hc/en-us/community/posts/203424746-Option-to-Exclude-Articles-and-or-Forums-from-Search-Results (I receive "oops, you're not authorized to access this page" when signed in)

---

https://support.zendesk.com/hc/en-us/community/posts/210251877-Prevent-articles-from-showing-in-search

Stub - no final answer

---

This topic has been closed for replies.

4 replies

  • August 19, 2019

I also couldn't find an ideal solution to this. I am using jquery, but removing rather than hiding, so the remove function is used only once to remove the unwanted elements. The jquery solution is not ideal because it works for one page of search results, but if the search results go over one page, the pagination is messed up and the total number of results at the top of the page is not always correct. I could not find any way to fix that. 

In case it's helpful to somebody, below is the code that removes articles with 'Forms' in the title from the search results. (We need to hide articles with 'Forms' in the title, because those articles contain HTML to display icons that users click to open forms. When those articles appeared in the search results, they looked very strange when opened, as they are code and not text.)

var formsResults = $('.search-results-list .search-result a.search-result-link:contains("Forms")');
 if (formsResults.length) {
  formsResults.parent().remove(); // remove the elements where articles have 'Forms' in title

  // Adjust the number of results in search results heading
  var numResults = $('.search-results-list .search-result').length;
  var searchResultsHeading = $('.search-results-heading').text();
  var partialHeading = searchResultsHeading.substring(searchResultsHeading.indexOf('for'));
  $('.search-results-heading').text((numResults > 0 ? numResults : 'No') + ' ' + (numResults !== 1 ? 'results' : 'result') + ' ' + partialHeading);

  // Add 'no results' element for knowledge base or community if needed
  adjustSearchResultElement('Knowledge base', 'No results ' + partialHeading, '/hc/en-us', 'Browse knowledge base', 'home');
  adjustSearchResultElement('Community', 'No results ' + partialHeading, '/hc/en-us/community/topics', 'Browse Community');
  }

  // If search result list exists and contains no results, add 'no result' element
  function adjustSearchResultElement(searchResultType, elementText, browseLink, browseText, browseTitle) {
    var subHeadingSelector = '.search-results-subheading:contains("' + searchResultType + '")';
    var searchResultListSelector = subHeadingSelector + ' + .search-results-list';
    var searchResultSelector = subHeadingSelector + ' + .search-results-list .search-result';
    if ($(searchResultListSelector).length && $(searchResultSelector).length == 0) {
      var elementTitle = browseTitle ? 'title="' + browseTitle + '"' : '';
      var htmlToAppend = '<p>' + elementText + '. <a ' + elementTitle + ' href="' + browseLink + '">' + browseText + '</a></p>';
      $(subHeadingSelector).after(htmlToAppend);
    }
}


Brett13
  • Community Manager
  • August 20, 2019

This is awesome. Thanks for taking the time to share this Karen!


  • February 13, 2020

I too would like the feature to remove individual articles or sections from search. While Karen's solution is great for her, it's not ideal for the rest of us.


  • February 13, 2020

@Molly Phillips

My solution is definitely not ideal when there is more than one page of search results. I was given a suggestion at https://support.zendesk.com/hc/en-us/community/posts/360034053994-Allow-article-to-be-excluded-from-search-results of a different way to hide articles that have a certain string in the title, but I couldn't get it to work. You could try it and see if it works for you.