Skip to content

Set site version in metatag

Sarah German requested to merge sarahg/version-metatag-redo into main

This MR re-applies the reverted changes from this MR with one functional difference: this does not change the value of the docsearch:version metatag.

The previous MR disrupted DocSearch by passing 15.5 for the pre-release version instead of main, which is what is already indexed at Algolia. Since search is faceted by version, querying with 15.5 returned no results and would have continued to do so until the site was re-crawled several hours later.

This MR adds a separate function for the DocSearch tag that will instead return the branch name if we're on the main/pre-release branch.

See also: !3190 (comment 1141756638)

How to test

  1. Configure a local GitLab Docs environment: https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/doc/setup.md.
  2. Check the HTML source for this tag: <meta name="gitlab-docs-version" content="15.5"> (it should exist and show 15.5 when you're on the main branch)
  3. Verify the docsearch:version metatag shows "main" as the content attribute.
  4. Verify the Versions drop-down shows the same version as the gitlab-docs-version metatag.
  5. Verify Algolia search returns results from the pre-release version (no change from current search behavior).

Merge request reports