Skip to content

Add anchors to Algolia indexes - #11976

Open
MarkvanMents wants to merge 2 commits into
MvM-BlankAlgoliaTextfrom
MvM-AlgoliaURLAddIndex
Open

MarkvanMents wants to merge 2 commits into
MvM-BlankAlgoliaTextfrom
MvM-AlgoliaURLAddIndex

Conversation

@MarkvanMents

Copy link
Copy Markdown
Collaborator

Summary

  • Each Algolia record's url field now includes a #anchor fragment 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 page
  • Heading id attributes are extracted from Hugo's pre-rendered HTML using findRE, tracked per heading level (h2–h6), and reset when a higher-level heading is encountered
  • Added an explanatory comment block at the top of the template describing its purpose, page selection, splitting approach, heading context tracking, and record fields

Test plan

  • Verify Algolia records include #anchor fragments in the url field
  • Verify anchors reflect the deepest heading in scope for each content chunk
  • Verify content before any heading uses the bare page URL with no fragment
  • Verify unique_hierarchy and heading fields are unaffected

🤖 Generated with Claude Code

@MarkvanMents

Copy link
Copy Markdown
Collaborator Author

Tested and uploaded to Algolia successfully.
image

@MarkvanMents
MarkvanMents changed the base branch from development to MvM-BlankAlgoliaText September 29, 2026 09:47
@OlufunkeMoronfolu
OlufunkeMoronfolu added this pull request to stack #11978 September 29, 2026 12:39
MarkvanMents and others added 2 commits September 29, 2026 14:46
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>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant