XF 2.1 Structured Data missing the publisher tag so gives error

maxicep

Active member
Xenforo 2.1 default DiscussionForumPosting markup gives Error on google structured data test tool.
So, it doesn't pass the test.

Errors are;
publisherA value for the publisher field is required.
mainEntityOfPageThe mainEntityOfPage field is recommended. Please provide a value if available.
Example URL Test Link


Ekran Resmi 2019-09-02 19.16.04.png

How can we put the Publisher (mandatory value) and mainEntityOfPage values to structured data vars.

Thanks
 

Chris D

XenForo developer
Staff member
I don't currently believe that those values are required, based on the actual schema and specification:

I see no reason why he publisher field would be required, or what relevance it has to a forum post.

Currently going to disregard this and hopefully the Google Structured Data tool will be corrected.

EDIT: Feedback has been sent using their tool (via the Cog > Send feedback menu).
 

maxicep

Active member
I don't currently believe that those values are required, based on the actual schema and specification:

I see no reason why he publisher field would be required, or what relevance it has to a forum post.

Currently going to disregard this and hopefully the Google Structured Data tool will be corrected.

EDIT: Feedback has been sent using their tool (via the Cog > Send feedback menu).
Is possible to add the Publisher tag manually until it fixing ?
via edit a File or like ?
 

Kevin

Well-known member
It's a result of Google thinking everybody wants to use AMP pages. Schema wise, DiscussionForumListing falls under SocialMediaPosting which falls under Article. For Article, Publisher is required for AMP enabled pages but not non-AMP pages.


I'm not finding a way of specifying that a page might have schema markup but it not AMP enabled. Oh, and just to add to the fun, if you do add Publisher to DiscussionForumListing/SocialMediaPosting/Article to a non-AMP page then the Publisher type must be Organization as it'll give a validation error if type Person is used. And Publisher type Organization? That requires a Logo value as well.
 

maxicep

Active member
Just ignore it. There won’t be any adverse effects.
I understand, and agree partially.

Anyway, i want to fix these errors because of i moved my forum to subdomain so i want to show the new indexes without any error in no where. We are already an organization so i want to put these value to my board's structured data, it isn't right?

+What is the file of these values affect it ?

Thanks
 

Kevin

Well-known member
+What is the file of these values affect it ?
As mentioned above, it's not required unless you are using AMP but it's easy enough to take care of.

In your thread_view template, look for "datePublished": "{{ date($thread.post_date, 'Y-m-d')|escape('json') }}", at around line #57 and then change it to the below. I'm using a template modification instead of a direct template edit for my purposes but XF2.x makes direct template edits easy enough to manage.

Code:
"mainEntityOfPage": {
    "@type": "DiscussionForumPosting",
    "@id": "{{ link('canonical:threads', $thread)|escape('json') }}"
},
"publisher": {
    "@type": "Organization",
    "name": "{$xf.options.boardTitle}",
    "logo": {
        "@type": "ImageObject",
        "url": "{{base_url(property('publicMetadataLogoUrl'), true)|escape('json')}}"
    }
},
"datePublished": "{{ date($thread.post_date, 'Y-m-d')|escape('json') }}",
Note: The above assumes you have a metadata logo image specified in your ACP, if you don't or want to use a different image then you'll need to modify the URL of the logo property.
 
Top