Question
I do not want some of my articles to show in Help Center searches. Can I exclude an article from search results?
Answer
No, there isn't a default function in the Help Center to exclude an article from search results, however, we have the following workarounds:
- Using restricted content in your Help Center: by restricting the access to articles to only certain users, the articles will be excluded from the search results for unauthorized users too.
- Putting the article into Draft mode: mark the article you wish to exclude from the search as a Draft, simply click Edit Article > mark it as a Draft > Update.
- Using custom JavaScript or jQuery, specifically the .hide function in jQuery would be the best option for custom code.
For more information on how to exclude articles from search engines like Google and Bing, see the article: How can I restrict my articles to not appear in search results from search engines?
19 Comments
I'm trying to add an article in draft mode, but I cannot see this option. In edit mode there is no draft/published in the top right as indicated in the screen shot above.
How do I control draft/published?
Hi Alison!
As long as you're in edit mode, that option should definitely show up for you. Can you post a screenshot of what you're looking at?
I see there is mention of a jQuery code to hide a document from search results, would someone be able to give more info on how to accomplish this? I have an article that is hidden but published and viewable by anyone and hiding it from the search is my last thing to figure out so that it's only available to those with the link.
Hi Dave!
I too am trying to create an article that is published and only accessible if you have the link for it, and is not searchable. Curious how you accomplished the first part of not making it appear in any categories/sections, did you use a div tag or something? Thanks in advance for your help!
Hey, Dave and Chris!
I did some poking around to see if anyone had actually posted code for this, and I didn't find anything for this specifically.
However, I did find a tip from one of our Moderators, Andrea, with code to hide an article's author from search results.
My thought is that this code might be able to serve as a jumping off point, with some strategic changes made to hide the article completely.
Keep us posted on how you get on! If you get stuck, let us know and I'll try to find a Moderator who can help you troubleshoot - we've got a couple folks who are good at this kind of thing. And if you do get it figured out on your own, it would make a great contribution for our Tips & Tricks section. :)
Hi, this does not really work for us as we don’t want to enforce our users to have to sign in, our restrict them to being part of an Organisation. We simply want to hide the articles from Category/Section/Article view, which we’ve done with curlybars, and then simply not have the hidden articles return in the Help Centre search results.
Is there no way to do this?
Hey Ian!
I can't speak to how it would work to restrict search results with JS, but I imagine you could probably figure out a way to do it.
That said, it would be much easier to just restrict the individual sections you don't want your logged-out users to see. You can restrict them by tag or org, which will automatically hide them from logged-out users. No need to force anyone to log in or anything.
Howdy,
I have some code which works (albeit haggardly) for this. If you want to hide an article called "Secret Article", plug in the following code:
if($('li.search-result a:contains("Secret Article")').length > 0)
{
$('li.search-result a:contains("Secret Article")').hide();
$('li.search-result a:contains("Secret Article")').next().hide();
$('li.search-result a:contains("Secret Article")').next().next().hide();
}
I had to run the .hide() function three times to hide the title, author, and details, respectively.
This is useful if you have an article that you want to link to a certain subsection of your readers, but don't want people surfacing it in the Zendesk search.
Hope this is of help to someone!
Cale, would this work by using a label called "secret article"?
Hi Kalle,
No, this code wouldn't work by adding a label.
The code works by detecting the title of the article. Whatever the title of the article you want to hide, change "Secret Article" in the code to the name of that article.
Cheers,
Cale
Ah. Got it! Thanks a lot Cale
Hello Cale,
I am not sure if you are able to help, I am looking for a way to hide a whole category from the help centre search. I am not sure if you are anyone else knows how this can be done?
Many thanks,
Drew
Hi Drew,
If I check out the page in Chrome developer tools:
We can see that the category name is displayed inside the <div> with a class "search-result-meta". So we can use jQuery selectors to find all the category links which include a specific term (the name of the category).
If your search results page includes the category, this should be possible.
For example, on my search page, this is the category:
In my example, if I wanted to hide the "Billing" category, my code would look something like this:
if($('div.search-result-meta a:contains("Billing)').length > 0)
{
$('div.search-result-meta').parent().hide();
}
I doubt the above code would actually work, but the idea would be to find every div that contains a link with your category name, and then, if the category name is present, hide the parent element (the <li> item that is displayed in the search results). With some fiddling, you can probably get it done.
Hope this gets you on the right track!
Cheers,
Cale
Hello Cale,
Thank you for the quick reply. Unfortunately I believe you are correct that this will not work, the category is not displayed but the articles within it.
I was hoping there may be a way to blanket remove all items from search that are associated to a category?
Many thanks for your reply
Drew
Hi Drew,
I wish I had time to dig in to fixing this—I get a sick pleasure from solving these little problems—however, I'm quite busy right now. Perhaps try posting some code snippets along with your technical challenge to stackoverflow.
If you can't wrangle through the jQuery, you could consider making the section containing the articles visible only to signed-in users. That would hide them from the search both in Google and on your site (if a user isn't logged in).
That's the only other option I can think of offhand—good luck!
Cheers,
Cale
Hi all,
I'm not sure that everyone understood the intent of the original poster (OP). The idea is to have a public Zendesk article; however, some (or all) of the contents shouldn't be searchable via Zendesk's search feature. The good people at Zendesk have been clear that there is no feature to disallow the search of an article, and they've even offered a few workarounds.
I too use my own workaround for this situation and I think it falls more in line with what the OP had in mind. I'd like to share my solution with you. I use it for our XPunch employee time punch clock help desk, and you can see an example of just such a Zendesk article at https://xpunch.zendesk.com/hc/en-us/articles/360027671032-Product-Updates-and-Fixes
So, here's the thing: this particular article is a product update page. Every time we introduce a product feature, update, or fix,we want to be able to let our users know about it. The problem is that many words we use in this particular article would appear in a search when users are genuinely looking for product help—we don't want to confuse them by displaying a link to this list of product updates. For example, we might advise everyone in our Product Updates article that we've just added "timesheets" as a new feature to the employee time recorder, but we don't want the search keyword "timesheets" to point to this article in the search results—we only want articles that explain how to use timesheets correctly to workers that use XPunch.
So, the fix was easy: create a cloud document (I used Google Docs, but you can use anything that can be embedded on Zendesk), and embed the document into your Zendesk article. Zendesk won't be able to add the contents of your document to its search engine.
In the case of Google Docs, the embed code will look something like this:
To summarize, yes, it's still a workaround to getting text to not appear in Zendesk's search engine, but it's a quick and easy fix that allows articles to be public, yet not searchable.
Alright, sharing for who else stumbles upon this: I fiddled around with this, and got a little further, although it's also a bit of a Frankenstein workaround.
If you want to hide articles from a specific Section or Category, you can do the following:
First, find your search results section, and specifically something like this:
Anywhere under there add the following (if you don't already have the {{meta}} object anywhere that is)
You can choose to hide this or not, doesn't matter. The important thing is that with this, we pull in the Categories and Sections that the individual search results fall under.
After that, a bit lower on the page, add the following jQuery script snippet:
This finds the div you added, with the class hidden-articles-meta. Then it checks if any links under it contain the words 'Restricted Content' (replace this with the name of the Section/Category you want to hide articles for).
That should do the trick.
I've found one issue with it though: It cuts the results out of the page, and doesn't fill them up with new results. So your paginations becomes a bit weird, as it could be that it cuts a lot of the results out and only leaves 2 results on the first page, with 10 results on the 2nd page. Anyone with a solution to that, please let me know ;)
If Zendesk could add more objects, that would be greatly appreciated to make customization easier. In this case, Objects for article IDs, Category IDs etc would help.
Floris - I have a somewhat messy way to fix the "10 results" when you are excluding some of the search results.
I created three javascript variables: (1) totalArticles that adds up all of the returned search results by placing it inside the {{#each article_results}} guide helper block, (2) hiddenArticles that used a similar jQuery snippet to the one you posted using .length instead of .remove() to add up the number of results that were removed, and (3) visibleResults which is just #1 minus #2.
I then just used innerHTML to append the value of visibleResults before the rest of the "results for {{query}}" header.
I have a solution similar to Floris's for when you want to hide an entire section from search results, but this one does not require jQuery.
Using Handlebars, you can hide a result from your search_results.hbs by wrapping the result in a hidden div if the result is in the section you want to hide. To hide a section called "Notifications", you would use code like this to start:
And then close your div at the end of your template:
The whole thing might look something like this:
The caveat Floris called out is the same; you will no longer have 10 results per page as results are hidden. I also want to call out that while this will hide results from the search results page, it will not hide anything from being suggested as one types in the search bar. One more thing: we don't have any categories in our help center, just sections, so it is possible you may have to tweak this code a little if you have both categories and sections. Still, I hope this is helpful for someone else!
Please sign in to leave a comment.