Skip to content

Fix invalid breadcrumb JSON-LD schema on taxonomy pages#611

Merged
duncanmcclean merged 1 commit into
7.xfrom
json-ld-taxonomy-breadcrumbs
Jun 19, 2026
Merged

Fix invalid breadcrumb JSON-LD schema on taxonomy pages#611
duncanmcclean merged 1 commit into
7.xfrom
json-ld-taxonomy-breadcrumbs

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where the BreadcrumbList JSON-LD schema rendered an invalid itemListElement on taxonomy term pages — an object with non-sequential numeric keys and gaps (e.g. {"0":{...position 1...},"2":{...position 3...}}) instead of a sequential array.

This was happening because the nav:breadcrumbs tag drops any taxonomy crumb whose template doesn't exist, and Laravel's reject() preserves the collection's keys. When SEO Pro then mapped over the breadcrumbs, it used the collection key as the position, so the leftover gapped keys produced non-sequential positions and ->all() serialised the result as a JSON object rather than an array. Regular entries weren't affected because every URL segment resolves to a viewable page, so nothing gets dropped.

This PR fixes it by calling ->values() on the breadcrumbs before mapping, re-indexing the collection so positions are contiguous (1..n) and the output is always a sequential JSON array.

Fixes #608

@duncanmcclean duncanmcclean merged commit 39acccf into 7.x Jun 19, 2026
17 checks passed
@duncanmcclean duncanmcclean deleted the json-ld-taxonomy-breadcrumbs branch June 19, 2026 10:06
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.

Invalid breadcrumb schema on taxonomies

1 participant