Skip to content

Add a metatag with page trail

Sarah German requested to merge gps-breadcrumbs-metatags into main

What does this MR do and why?

In !4011 (merged), we added a JSON-LD schema to each page that defines its breadcrumb trail, based on the global nav. Google uses this to show a breadcrumb trail alongside search results.

However, this data is not included in responses from the Google Programmable Search JSON API as expected. Turns out that Programmable Search Engine (PSE) only passes a very limited subset of these schemas to search results when using PSE.

We can work around this by including the breadcrumb trail in a metatag. Custom metatags are passed alongside search results from the API (we use the metatag approach for the section filters on the results page).

This MR uses output from the function added in the previous breadcrumb MR, just formatted as a string, and adds that to a metatag which is included site-wide.

References:

Screenshots, screen recordings, or links to review app

View HTML source of pages and look for the gitlab-docs-breadcrumb metatag. Each page in the hierarchy should be separated with a comma. For example, the tag should look like this for a 6th-level page:

<meta name="gitlab-docs-breadcrumbs" content="Use GitLab, Build your application, CI/CD, Auto DevOps, Customize, Multiple Kubernetes clusters">

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: make compile
  3. Verify nothing crashes during compilation
  4. Verify pages include the gitlab-docs-breadcrumbs metatag. On a page that is not in the nav (e.g, the homepage), the tag should exist, but its content will be empty.

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