Skip to content
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

Structured data support in Protostar #7192

Closed
wants to merge 1 commit into from
Closed

Structured data support in Protostar #7192

wants to merge 1 commit into from

Conversation

laoneo
Copy link
Member

@laoneo laoneo commented Jun 18, 2015

When an extension enriches it's content with schema.org meta data, then the W3C validator will complain like

The itemprop attribute was specified, but the element is not a property of any item.
<p itemprop="startDate" content="2015-06-18T21:35:00+00:00">

This situation can easily be solved with the proposed code change.

Test instructions:

  • Download the Free version of DPCalendar from https://joomla.digital-peak.com/download/dpcalendar
  • Install it on your test server (preferable accessible from the internet)
  • Create some events in the future in DPCalendar
  • Publish the DPCalendar upcoming module on all pages
  • Open a page on the front
  • Copy the url in the browser address bar to https://validator.w3.org and run the validation
  • Before the patch is applied tons of the above errors will be shown, after the patch none of the above error should be reported in the validator

When an extension enriches it's content with schema.org meta data, then the W3C validator will complain like

`The itemprop attribute was specified, but the element is not a property of any item.
<p itemprop="startDate" content="2015-06-18T21:35:00+00:00">`

This situation can easily be solved with the proposed code change.
@0sh0
Copy link

0sh0 commented Jun 18, 2015

I second @laoneo on this request. Please consider applying this patch.

@brianteeman
Copy link
Contributor

@0sh0 With any patch it is not about voting for it but testing it. If you want to see this being applied then please follow the testing instruction and report your findings

@Bakual
Copy link
Contributor

Bakual commented Jun 18, 2015

My feeling is that this microdata stuff is getting ridiculous. What value is there to define a HTML page as "webpage"? Aren't all HTML pages webpages?

Even schema.org seem to agree with that (from https://schema.org/WebPage):

A web page. Every web page is implicitly assumed to be declared to be of type WebPage, so the various properties about that webpage, such as breadcrumb may be used. We recommend explicit declaration if these properties are specified, but if they are found outside of an itemscope, they will be assumed to be about the page.

So it should be valid even without that itsemscope.

Your example is probably a bad example, as "startDate" isn't a valid property for a WebPage if I read https://schema.org/startDate correctly. It should be contained in an "Event" type.

@laoneo
Copy link
Member Author

laoneo commented Jun 19, 2015

The example I've posted is an excerpt of a complete structure within an event which looks like when you install the upcoming module. You can think about this as scopes. A root scope is the WebPage and it can contain other elements like Events and so on. Did you understand it?

The upcoming module creates the following structure, which is valid structured data:

<div itemprop="event" itemscope="" itemtype="http://schema.org/Event">
    <p style="clear: both;"></p>
    <div class="dp-upcoming-calendar">
        <div class="dp-upcoming-calendar-background" style="background-color: #B310CC"></div>
        <div class="dp-upcoming-text-month">Jun</div>
        <div class="dp-upcoming-text-day" style="color: #B310CC">20</div>
    </div>
    <p itemprop="startDate" content="2015-06-20T00:00:00+00:00">
        06.20.2015      <br>
        <a href="/demo/dpc/en/7999.html" itemprop="url" class="dpc-upcoming-event-link">
            <span itemprop="name">Full Day Event</span>
        </a>
    </p>
    <div itemscope="" itemtype="http://schema.org/PostalAddress" itemprop="location"><meta itemprop="name" content="Washington"><meta itemprop="addressLocality" content=""><meta itemprop="addressRegion" content=""><meta itemprop="postalCode" content=""><meta itemprop="streetAddress" content=" "><meta itemprop="addressCountry" content="Washington"></div> <p style="clear: both;">
</p></div>

@Bakual
Copy link
Contributor

Bakual commented Jun 19, 2015

The event property isn't a valid property for a WebPage neither. See https://schema.org/event.
So while it would please the W3 checker, it still produces wrong structured data and the Google checker (https://developers.google.com/structured-data/testing-tool/) will show it as an error.

I would suggest you just remove the "event" itemprop from your module. This is the real issue as it will be an invalid property on most pages anyway.

@Fedik
Copy link
Member

Fedik commented Jun 19, 2015

This suggestion does not fix and does not really improve something.

I am agree with @Bakual ,
And I do not really understand why you force Event to be children of WebPage, it have no any sense.
Just do as in examples https://schema.org/Event 😉

upd: check that http://webmasters.stackexchange.com/a/52592

@laoneo
Copy link
Member Author

laoneo commented Jun 19, 2015

The problem is that the upcoming module delivers multiple events which must be wrapped inside a root itemprop. The problem is that the W3C validator fails and reports the problems mentioned in the description. The fix is not something it did out of curiosity, but a suggestion from SO http://stackoverflow.com/questions/29123445/validation-error-the-itemprop-attribute-was-specified-but-the-element-is-not. The HTML code generated by the module is absolutely fine.
Removing the property is not a valid option as it is more and more important to deliver structured data beside the HTML code.
Digging a bit further on this, when I wrap multiple events inside a Thing div, then it starts to become valid. So I found a workaround, thanks to your inputs.
I still think it has it's right to to put the whole site inside a WebPage. Structured data is also used by com_content, so it would be ok to us it in a template. I agree with @Fedik that it doesn't fix something, but it definitely helps the search engines indexing the Joomla pages which use protostar (probably not many production sites do use it).

@laoneo
Copy link
Member Author

laoneo commented Jun 19, 2015

A better explanation why it could make sense to wrap the whole page inside a WebPage
http://webmasters.stackexchange.com/questions/52570/linking-several-separated-microdata-divs-together/52592#52592

@Bakual
Copy link
Contributor

Bakual commented Jun 19, 2015

You can have the Event as a standalone scope. It doesn't need to be tied to a root element at all. So just remove the itemprop but leave the scope and type in. Then it's valid.
The itemprop would require the parent type to be one of

  • InformAction
  • InviteAction
  • JoinAction
  • LeaveAction
  • Organization
  • Place
  • PlayAction

@Bakual
Copy link
Contributor

Bakual commented Jun 19, 2015

A better explanation why it could make sense to wrap the whole page inside a WebPage
http://webmasters.stackexchange.com/questions/52570/linking-several-separated-microdata-divs-together/52592#52592

Actually, that link says the same as I do. Wrapping it into a "WebPage" type is invalid:

If a parent element specifies another item (e.g., a WebPage on the body), the above solution does not work because then the event property would also apply to the WebPage, which would not be correct.

@laoneo
Copy link
Member Author

laoneo commented Jun 19, 2015

Thanks for your solution @Bakual it indeed does work. Got a free tutorial about structured data :-).

@Bakual
Copy link
Contributor

Bakual commented Jun 19, 2015

You're welcome.

My head exploded a year ago when I read up on that stuff. I still can remember a bit of it though 😄

Closing as it's resolved.

@Bakual Bakual closed this Jun 19, 2015
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.

6 participants