Skip to content

Conversation

@Mridul012
Copy link

Summary

This pull request fixes an issue in the documentation search index generator
(scripts/generateSearch.js) where URLs containing headings without an id
attribute would incorrectly include #undefined in the final link. This caused
broken navigation when clicking certain results in the documentation search.

What was the problem?

The script assumes all <h3> tags have an id and always appends
#${el.prop('id')} to the generated URL. When the id is missing, URLs like the
following were inserted:

What does this PR change?

Adds a null/undefined check before appending URL hash fragments:

  • If an id exists → append #id
  • If not → return the base page URL

This prevents broken URLs in the search index.

Verification

Verified locally by running:

node scripts/generateSearch.js

@vkarpov15 vkarpov15 added this to the 9.0.1 milestone Nov 25, 2025
@vkarpov15 vkarpov15 merged commit b33c55d into Automattic:master Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants