Add anchors to Algolia indexes - #11976
Merged
Merged
Conversation
After plainify strips HTML tags from heading elements, trailing \r, \n, and other whitespace remained in the h2-h6 fields because htmlUnescape alone does not trim. This caused dirty values in those fields and in the unique_hierarchy breadcrumb string. Replaced htmlUnescape with strings.TrimSpace (htmlUnescape ...) for all five heading levels. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each content record's url field now includes a fragment pointing to the deepest heading in scope (e.g. /refguide/entities/#entity-types). Hugo's rendered HTML already carries id attributes on all headings, so the id is extracted with findRE as each heading chunk is processed and tracked per level alongside the existing heading text variables. The deepest non-empty anchor is appended when writing the url field, so search results in Algolia link directly to the relevant section rather than the top of the page. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the brief original comment with a full description of the template's purpose, page selection criteria, content splitting approach, heading context tracking, record fields, and empty-text exclusion. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
Author
MarkvanMents
changed the base branch from
development
to
MvM-BlankAlgoliaText
September 29, 2026 09:47
OlufunkeMoronfolu
added this pull request to stack #11978
September 29, 2026 12:39
OlufunkeMoronfolu
force-pushed
the
MvM-AlgoliaURLAddIndex
branch
from
September 29, 2026 12:46
1d6eec1 to
d4440e7
Compare
After plainify strips HTML tags from heading elements, trailing \r, \n, and other whitespace remained in the h2-h6 fields because htmlUnescape alone does not trim. This caused dirty values in those fields and in the unique_hierarchy breadcrumb string. Replaced htmlUnescape with strings.TrimSpace (htmlUnescape ...) for all five heading levels. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each content record's url field now includes a fragment pointing to the deepest heading in scope (e.g. /refguide/entities/#entity-types). Hugo's rendered HTML already carries id attributes on all headings, so the id is extracted with findRE as each heading chunk is processed and tracked per level alongside the existing heading text variables. The deepest non-empty anchor is appended when writing the url field, so search results in Algolia link directly to the relevant section rather than the top of the page. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the brief original comment with a full description of the template's purpose, page selection criteria, content splitting approach, heading context tracking, record fields, and empty-text exclusion. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
MarkvanMents
force-pushed
the
MvM-AlgoliaURLAddIndex
branch
from
September 30, 2026 14:31
d4440e7 to
896ae2c
Compare
Collaborator
Author
|
Discussed and approved by Olu. |
MarkvanMents
removed this pull request from stack #11978
September 30, 2026 14:35
MarkvanMents
changed the base branch from
MvM-BlankAlgoliaText
to
development
September 30, 2026 14:36
… into MvM-AlgoliaURLAddIndex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
urlfield now includes a#anchorfragment pointing to the deepest heading in scope (e.g./refguide/entities/#entity-types), so search results link directly to the relevant section rather than the top of the pageidattributes are extracted from Hugo's pre-rendered HTML usingfindRE, tracked per heading level (h2–h6), and reset when a higher-level heading is encounteredTest plan
#anchorfragments in theurlfieldunique_hierarchyand heading fields are unaffected🤖 Generated with Claude Code