-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breadcrumbs SEO microdata includes invalid values for IDs if no href #7241
Comments
Hi, we're aware of this issue. What do you propose to solve this (because we didn't add |
Ultimately I believe there's a mismatch between Docusaurus' model of breadcrumbs and Google's expectation. It seems like in the eyes of Google a breadcrumb should only exist if it links to something*. However this isn't (please correct me if I'm wrong) the Docusaurus model: for Docusaurus, a category linking to nothing is a valid breadcrumb. I have (AFAIK) no way to control Docusaurus' breadcrumb generation, so I can't really add an * My personal view: a breadcrumb without a link isn't really a breadcrumb and shouldn't be added to the page. Each breadcrumb is meant to represent a page the user has visited to get to their current page. The user never visited a category page, so there should be no item for that. This would also solve the microdata issue. |
Alternatively I could add an actual page for each category, that just links to items in the category. But the issue still stands that the breadcrumbs generated by Docusaurus don't represent clickable pages in all cases (and IMO they should). |
Just linking up issues and PRs: |
@fnune You can. The breadcrumbs are generated from the sidebar structure, so as long as each sidebar category has an index page, the breadcrumb will also have an Note that the Google console message is only a warning, and I believe SEO won't be undermined by this. Again, I'm fully aware (all the way back when I sent #6697, I even noted in the PR description), I do believe this is terrible, but I don't know of a way to fix this. If you do, please kindly inform me. Otherwise, this issue is basically unactionable. Update: this might be possible if we allow custom breadcrumb target links. See #6953 |
I think the warning "Add an index page for each category" sounds like a good idea. It's not only a potential SEO problem, it's also a UX issue because the breadcrumb that's generated isn't clickable. I will follow your suggestion of adding index pages to category entries. On another note, do you think I should file a different issue for this?
E.g. "Generate no breadcrumb for category sidebar entries without a page". |
That sounds like a viable solution as well. Users should be able to efficiently filter out all breadcrumbs without links because the UX could be potentially confusing. Again, we could either (a) try to figure out a better heuristic so that all items have href or (b) ask users to explicitly provide an href if there's no category link, once we have #6953 |
Defaulting to |
A problem with this would be that the shorthand syntax encourages sidebar items that are not really links and potentially don't need to be. E.g. https://docusaurus.io/docs/sidebar/items#using-shorthands So I think:
(a) is difficult (can't always generate a proper link), but (b) might be OK as long as there's e.g. a build error? |
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. |
You're right, thanks for the nudge. That pushed me to amend my own PR on my docs site.
Sounds reasonable. That would also be a solution to this issue. |
Quick update: After applying the suggested fixes, now Google still gets a bad ID from only the last item in the breadcrumbs. See the breadcrumbs in https://docs.memfault.com/docs/mcu/arm-cortex-m-guide/ And the attached rich results test... results here https://search.google.com/test/rich-results/result?id=hIFxmU6Zz2gIigWiHig8_w HTML for that last breadcrumb item: <li
itemscope=""
itemprop="itemListElement"
itemtype="https://schema.org/ListItem"
class="breadcrumbs__item breadcrumbs__item--active"
>
<span class="breadcrumbs__link" itemprop="item name">ARM Cortex-M</span>
<meta itemprop="position" content="3">
</li> |
This is fixed by #7179 already. |
Sweet, thanks! Leaving it up to you whether to keep this issue around or close it. I believe it still represents a problem of bad defaults which leads to the generation of bad SEO microdata. If you'd like me to I can also submit a different issue for that, and then we can close this one. |
I don't know what's a good call. The only ways we can meaningfully move this forward are: (a) Find a way to tell Google to not generate Option (c) seems the most viable, but I'm also desperate trying to find an answer to (a), even just for curiosity's sake😅 But anyways, I'm going to go ahead and close this since if we agree that (c) is the best choice (and for the time being, you as user need to ensure that every category has a link). |
Some thoughts:
|
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) |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.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 anhref
and use it as theid
, it looks like if there's nohref
to take it default to whatever text is visible inside the element.So, if you have, e.g. a sidebar with nested items:
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:In these cases, I think it would be appropriate to not add an ID property at all.
Reproducible demo
No response
Steps to reproduce
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
The text was updated successfully, but these errors were encountered: