question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Breadcrumbs SEO microdata includes invalid values for IDs if no href

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I’m using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

If a breadcrumb item (such as a category item in the sidebar) has no link (and thus no href) the generated SEO microdata is invalid. Since the generator is designed to pick an href and use it as the id, it looks like if there’s no href to take it default to whatever text is visible inside the element.

So, if you have, e.g. a sidebar with nested items:

image

Then the generated breadcrumbs have no links associated to them. The generator takes, in this case "MCU Guides" as its ID, which is apparently invalid:

image

In these cases, I think it would be appropriate to not add an ID property at all.

Reproducible demo

No response

Steps to reproduce

  1. Add a nested sidebar to Docusaurus:
// E.g. in sidebar.js
module.exports = {
    docs: {
        "Some Category": {
            type: "category",
            label: "Some Label",
            items: [
                "some-category/actual-docs"
            ]
        }
    }
};
  1. Run the Google rich results validator on the resulting page: https://search.google.com/test/rich-results

Confirm that the ID of the SEO microdata is Some Category, which is invalid.

Expected behavior

No ID gets added in the generated SEO microdata for breadcrumbs without an href.

Actual behavior

An invalid ID gets added, using the text value from the category breadcrumb, because there’s no href to take from.

Your environment

Self-service

  • I’d be willing to fix this bug myself.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:17

github_iconTop GitHub Comments

2reactions
Josh-Cenacommented, Apr 25, 2022

No, not defaulting category indexes, because that doesn’t make much sense. But defaulting breadcrumb links is something we can do (i.e. even if there’s no category link, we can find a link, like the first doc). In fact, we already have such algorithm: if JS is disabled, you can still navigate through the categories, because each category will always have a link that’s clickable, just that it may be removed after React hydration.

1reaction
Josh-Cenacommented, Apr 27, 2022

If breadcrumb does not have link, we could remove the microdata?

I thought about that at the time I was implementing it, but I don’t like the idea. A breadcrumb item should be allowed without a link (at least the schema allows it, not to say it’s any good for SEO anyways)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rich results test detects error "missing field 'id'" while it is present
I am adding Microdata to my website's breadcrumbs. When testing my own code, I am getting the error that the field "id" is...
Read more >
How To Add Breadcrumb (BreadcrumbList) Markup
A breadcrumb trail on a page indicates the page's position in the site hierarchy, and it may help users understand and explore a...
Read more >
Ecommerce SEO, Part 7/8: Product Listing Pages (PLP ...
This e-commerce SEO guide has almost 400 pages of advanced, ... Technically speaking, these are not breadcrumbs, but rather filter values.
Read more >
A Guide to JSON-LD for Beginners - Moz
It is an implementation format for structuring data analogous to Microdata and RDFa. Typically, in terms of SEO, JSON-LD is implemented ...
Read more >
Site has no breadcrumbs, but still got Invalid URL in field “id ...
All suggestions are to disable the breadcrumb. But there is no breadcrumb on my site to begin with. Even on Yoast SEO it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found