Skip to content

Scroll to search query on result pages

Sarah German requested to merge gps-search-result-scroll into main

What does this MR do and why?

This MR adds a ?query=yourTerm string to the end of search result URLs for specific pages. When you visit a page linked from your search results, if there's a heading on the page that matches the URL query string, we scroll you down to it

For example, if you search for include and click the .gitlab-ci-yml keyword reference page from the result list, you should land down here: https://gps-search-result-scroll.docs.gitlab-review.app/ee/ci/yaml/?query=include

For now we are limiting this to only the CI keywords page.

See #1692 (closed)

Screenshots, screen recordings, or links to review app

Try searching for a CI keyword ("needs" "artifact" "cache" etc) on the review app: https://gps-search-result-scroll.docs.gitlab-review.app/

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 the site to use Google search, and run a search for a CI keyword. (This feature will also work with Lunr, but Lunr rarely returns the CI keywords page as a result.)
  3. Click on the CI keywords page in the result list.
  4. If the page includes a heading that matches your search query, you should be scrolled down to that heading.
  5. If you click on a result that is not the CI keywords page, there will not be a ?query=yourTerm in the URL, and no auto-scrolling on the result page.

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