Knowledgebase

How to hide content from search results in Drupal

The core modules that come prepackaged with Drupal do not provide options for restricting content from being displayed when a user performs a search with the built-in search function. If you want to hide content from search results, you can do that with a contributed module called Search Configuration. You can use it to hide all nodes from a content type for specific user roles, or you can hide just individual nodes regardless of their content type. In addition to that it provides some extra options.

The module is installed as most other modules. There are no special requirements. If you need more information on how to install contributed modules, check out the article on installing modules in Drupal.

After you install the module you can configure its permissions. To do this, in the admin panel of your Drupal click on the People tab, on the page that opens click on the Permissions sub-tab and on the following page scroll down to the section Search Configuration. If you want users belonging to a particular user role to be able to search only through nodes from a specific content type(s), unmark the checkbox corresponding to the user role for the permission Search all content types and mark the checkbox(es) of the permission that allows to search through the particular content type(s) (e.g. Article:Search content of this type). Don't forget that in order for users from a particular user role to be able to use the search function at all, they should be allowed to do that from the respective permissions of the core Search module; these permissions are on the same page, just above those for the search configuration module.

If you want to, you can hide only particular nodes/content items from search results. To do this you have to edit the settings of the node. In the admin panel click on the Content tab, then on the page that opens find the node in the table and click on its edit button. On the page with the node settings scroll down to the bottom of the page and click on the Publishing options button on the left. A few options will appear on the right; mark the checkbox for Exclude from search and click on the Save button. In this case you should also make sure that the Search excluded content permission is not enabled for the user role for which you want the exclusion to apply. You can check that from People tab>Permissions sub-tab (Search Configuration section).

Was this answer helpful?

 Print this Article

Also Read