Search by Page

Last updated on
30 April 2025

The Search by Page module is an enhancement to the core Search module. This handbook page explains what the module does, how to install and configure it, and how best to use it.

NOTE: This page gets out of date frequently. For up-to-date information on how to install/configure/use this module, check the README file.

What Search by Page Does

The Search by Page module was designed to get around several limitations of the core Search module, which come up for some (but perhaps not all) Drupal sites:

  • In Search, all of the Node content on your site will be searchable, whether you want it to be or not. Search by Page lets you decide which content should be searchable, so (for instance) you can exclude "database table" content types you may have defined (content types meant to be displayed only in Views or as parts of other pages, not on their own).
  • In Search, only Node content on your site will be searchable and the User search only searches user names (not profile fields). Search by Page lets you search pages generated by Views, User Profiles, Panels pages, file attachments, etc.
  • In Search, the content that is indexed for searching for a given node is generated by loading the node and indexing the resulting "body" field (i.e. the node as it would appear in the absence of a customized theme). Search by Page indexes the "content" pane of each page as rendered by your theme (excluding headers, footers, sidebars, and other block regions).
  • Search by Page is language-aware, so it only shows you results in the current language.
  • Search by Page has multiple search "environments", so you can have different search pages/blocks to search different things.

Installation and configuration

Here are the steps you need to follow in order to install and configure Search by Page:

  1. Download the zip file from the module page, upload it to your site, and enable the module in the normal manner.
  2. Choose and enable one or more Search by Page sub-modules, to tell Search by Page what pages on your site should be indexed for searching. Search by Page currently comes with four sub-modules:
    • Nodes: indexes nodes of particular content types.
    • Users: indexes user profile pages for users of particular roles.
    • Paths: indexes arbitrary paths to pages on your site, such as Views pages. This is the most generic sub-module, but if you put a lot of paths in it, your searches will run slower. (The technical reason is that each time someone searches on your site, this module has to check whether that person has permission to view each page in the list, to exclude pages the person doesn't have permission to view from search results, and this has to be done via a PHP loop rather than an SQL query because of how Drupal permissions work.)
    • Attachments: indexes the text in certain types of files that are attached to nodes via either the CCK FileField module or the core Upload module (Drupal 6.x) or the core File field (Drupal 7.x). This requires "helper" programs to extract the text from file attachments, and the helper programs are configured using the separate Search Files API module (which you can find at http://drupal.org/project/search_files - for Drupal 7.x see issue #712002: Port to Drupal 7 to download a working version). It is recommended that you download Search Files 6.x-2.x or later (which may be a "Beta" version, but that is OK), and only enable the Search Files API module (and not the other included modules). This will enable just the helper program setup functionality, without enabling the other functionality of Search Files.
    • You can also write your own sub-module to define another group of pages to index. See the API README file distributed with the module (or use one of the included sub-modules as an example).
  3. Visit the Search by Page configuration page (under Admin / Settings in Drupal 6, Admin / Configuration / Search in Drupal 7) to configure the module and define what should be indexed for searching. As of version 6.x-1.8 and later, Search by Page configuration is organized into "environments", and each environment is composed of several settings. So you will first need to create an environment or edit the default environment. Next, on the environment edit screen, choose one or more node content types (if you enabled Search by Page Nodes), user roles (if you enabled Search by Page Users), node types for attachments (if you enabled Search by Page Attachments), or paths to pages on your site (if you enabled Search by Page Paths) to be indexed. Until you do this step, Search by Page will not try to index anything on your site, and nothing will be searchable.
  4. Ensure that cron is set up correctly and has been run, to update the search index. See the cron setup page in the Handbook for more information. You can check on how much of your site has been indexed for searching by looking at the Search module configuration page (there's a link to that page from the Search by Page main configuration page). Until the index is complete, searching will return no or incomplete results.
  5. In Drupal 7, make sure that Search by Page is checked as an enabled search module on the core Search configuration page.
  6. Visit your site's Permissions page and grant permissions for each of your search environments. You may also need to make sure that the core "search content" permission is enabled for users who need permission to search.
  7. Decide how you want to deploy Search by Page. You basically have two choices:
    • You can deploy Search by Page as a tab on the core Search results page, in addition to the existing Content and User search tabs; it will use the default environment you have set up and ignore all other search environments. All you need to do to deploy Search by Page in this way besides the above configuration steps is to make sure users have permission to use Search on your site, and to search your default environment, and you can ignore the rest of the configuration steps below. It's important to choose a good name for your search tab in the Search by Page configuration screens, because in Drupal 6 you cannot turn off the "Content" and "Users" tabs in core Search. Also, depending on your configuration settings, there may be overlap between search tabs (e.g. if you use Search by Page Nodes or Search by Page Users, the Search by Page tab will contain Nodes and Users).
    • You can deploy Search by Page as a stand-alone feature. The rest of the configuration steps below assume you have made this choice.
  8. Optionally, enable the Search by Page blocks for each environment, on your Blocks administration page; these are blocks where site visitors can enter keywords to search the site via stand-alone Search by Page.
  9. Optionally, add links to the paths you have set up for your search environments' search pages to your site's navigation menus. They will automatically be in the Navigation menus, but you can add them to other menus if desired.
  10. Optionally, change the label and title settings for the block and/or page, for each environment.
  11. Optionally, change settings in the Search module that govern how many pages are indexed each time cron runs; these options are on the Search module configuration page.

Usage

Once you have Search by Page installed and configured correctly, and cron has run sufficiently to index your site, there are three ways to perform a search, depending on the deployment option you chose above:

  • If you chose the "deploy within Search" option, when you do a site search, you can click on the search by page tab to search within Search by Page for the same keywords.
  • If you enabled a Search by Page block for a particular environment, you can enter keywords to search only within that Search by Page environment.
  • If you navigate to the for a search environment on your site, you can search within that Search by Page environment.

The core Search module only matches exact keywords, and Search by Page uses the same technology. To get around this and allow matching such as "walk", "walking" and "walked" all matching, use a "stemming" module with Search by Page. For American English-language sites, use Porter-Stemmer. For non-English sites, search drupal.org for "stemming" or "stemmer" and then restrict the search to modules, and you might find something for your site's language.

You'll probably also want to tell external search engines what to index. Try the XML Sitemap module.

Further Reading

Questions, Comments, and Problems

If you have questions, comments, or problems regarding this module, PLEASE do not comment on this page. Instead, first check the Search by Page issue queue to see if your issue has already been addressed. If not, file a new issue there. That is the best way to contact the maintainer of this module. Thanks!

Help improve this page

Page status: Not set

You can: