Skip to content

Allow searches using 'query' as a parameter

Sarah German requested to merge gps-query-str-backwards-compat into main

What does this MR do and why?

URLs with a query string will trigger a search on the search page: https://docs.gitlab.com/search/?q=computers

Before we switched to Google, the query string looked like this: https://docs.gitlab.com/search/?query=computers

Because the Handbook documents visiting the URL directly as a method to quickly run a Docs search (https://about.gitlab.com/handbook/tools-and-tips/searching/), we should be backwards-compatible by allowing query to be read as the query string, in addition to q (which is the Google default).

Screenshots, screen recordings, or links to review app

No visual changes.

You can validate this on the review app by visiting both these URLs. They should both return search results:

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Configure a local GitLab Docs environment: https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/doc/setup.md.
  2. Compile and run the local site with Google search:
make clean && GOOGLE_SEARCH_KEY="AIzaSyAUCkVNs7JsHYKISjVrVv1PGXg9WQr1MCQ" SEARCH_BACKEND="google" bundle exec nanoc compile
bundle exec nanoc view
  1. Verify you can see search results using both query parameters:

(If you use query=, you'll see the URL change to q=, but it should still work.)

Merge request acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sarah German

Merge request reports