-
Notifications
You must be signed in to change notification settings - Fork 754
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
Fixed an issue where Breadcrumbs had invalid metadata for disabled pages #4671
Conversation
Invalid Breadcrumb Metadata for Disabled Pages Fixes dnnsoftware#4667 Google Search Console complains about invalid metadata for disabled pages (Missing field "item"). The metadata for disabled pages should not be rendered as an "itemListElement". "itemListElement" lists need to have at least one "item", but there is no item getting rendered in case the page is disabled. Issue dnnsoftware#4667
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 176 and 186 look the same to me - both seem to append itemprop twice for enabled pages - is this intended?
Removed duplicate line
One can test the rendered breadcrumb with the rich results test: Testing it with Google search console may take a while. |
// Is this tab disabled? If so, only render a span | ||
if (tab.DisableLink) | ||
{ | ||
this._breadcrumb.Append("<span class=\"" + this._cssClass + "\">" + tabName + "</span>"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this change; it makes sense and makes things better. One potential issue I see is that we're removing a span
that wrapped the disabled page, which may have been used for styling. Should we continue to wrap this span
in another span
? We can't do anything if that span
was targeted using the metadata attributes, but it seems likely to me that there are themes which expect that wrapping element.
Thoughts @dnnsoftware/approvers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed as well that a nested span without an id or class has been removed - IMO the effect on skins should be minimal and rendered HTML is even clearer without.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback. I could try later today to wrap the span inside of an additional span. That would probably provide better compatibility unless CSS is selecting the itemprop="name".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested to put another span around the span and it looks the same visually. Shall I change the code accordingly? It adds to the DOM model and is less clean on the other hand imho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think at this point it's probably more likely to cause a problem if it's missing than to cause a problem by being added. Unless someone has a different opinion, please go ahead and add it in. Thanks!
Thanks @Andy9999! This looks good, we'll review and see if we have any feedback. We'll take care of the milestone and label. A pull request on GitHub is between two branches, so while the PR is open, any new commit that your push to your |
Added an additional span to improve compatibility with existing skins expecting a wrapping span.
OK, done. I have deployed it on our production site and tested it with the Google rich result test tool and it's still OK. Just for future PRs, how could I implement some sort of switch to have two flavors the right way (with and without the wrapping span)? I mean in a way not to slow down things too much, getting cached and so on. Is there some API to have a switch in the host or portal settings SQL tables for example? Or maybe it could be an option for the skin object? |
For a skin/theme object, you can add a new property. For example, you can see that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Added LegacyMode for the skin object. The default (LegacyMode="True") will render the span wrapped in a span. If setting it to "False" it will not wrap the span for disabled pages. This is made to optionally not render unnecessary HTML, while providing skin compatibility with the default setting.
You are welcome! Thank you for the additional info about the LegacyMode. I made another change and it is now rendering the span in a span by default (LegacyMode="True"). If someone doesn't like the wrapped span the skin object can be optionally set to LegacyMode="False" to not wrap it. :) In the meantime I got feedback from Search Console's verification as well for some of the pages that had the error and the issue it previously detected is marked as resolved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a couple of suggestions to switch around how the new property works.
Also, if we're adding a new property, I think we need to add it to BreadCrumb.xml
also.
@@ -31,7 +31,8 @@ public partial class BreadCrumb : SkinObjectBase | |||
|
|||
public BreadCrumb() | |||
{ | |||
this._navigationManager = Globals.DependencyProvider.GetRequiredService<INavigationManager>(); | |||
this._navigationManager = Globals.DependencyProvider.GetRequiredService<INavigationManager>(); | |||
this.LegacyMode = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.LegacyMode = true; |
Added new LegacyMode setting.
Co-authored-by: Brian Dukes <bdukes@engagesoftware.com>
Co-authored-by: Brian Dukes <bdukes@engagesoftware.com>
Renamed LegacyMode to CleanerMarkup and improved help text for new setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 Thanks!
Set new "CleanerMarkup" setting to false by default. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
👍🏻 thanks yall for helping me with my very first PR. |
Thank YOU @Andy9999 🎉 |
Invalid Breadcrumb Metadata for Disabled Pages Fixes #4667
Google Search Console complains about invalid metadata for disabled pages (Missing field "item"). The metadata for disabled pages should not be rendered as an "itemListElement". "itemListElement" lists need to have at least one "item", but there is no item getting rendered in case the page is disabled.
Issue #4667