FEATURE: Add structured data to follow Google's guidelines (#9764)

All Schema.org properties are optional, but Google has a set of
properties which are required.
This commit is contained in:
Dan Ungureanu 2020-05-14 10:42:01 +03:00 committed by GitHub
parent d226783405
commit b80128a973
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 5 deletions

View File

@ -36,9 +36,17 @@
<%- if include_crawler_content? %>
<% @topic_view.posts.each_with_index do |post, idx| %>
<div itemscope itemtype='http://schema.org/DiscussionForumPosting' class='topic-body crawler-post'>
<% if (u = post.user) %>
<% if (u = post.user) %>
<div itemscope itemtype='http://schema.org/DiscussionForumPosting' class='topic-body crawler-post'>
<div class='crawler-post-meta'>
<div itemprop='publisher' itemscope itemtype="http://schema.org/Organization">
<meta itemprop='name' content='<%= SiteSetting.company_name.presence || SiteSetting.title %>'>
<% if application_logo_url.present? %>
<div itemprop='logo' itemscope itemtype="http://schema.org/ImageObject">
<meta itemprop='url' content='<%= application_logo_url %>'>
</div>
<% end %>
</div>
<span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person">
<a itemprop="url" href='<%= Discourse.base_url %>/u/<%= u.username %>'><span itemprop='name'><%= u.username %></span></a>
<%= "(#{u.name})" if (SiteSetting.display_name_on_posts && SiteSetting.enable_names? && !u.name.blank?) %>
@ -51,6 +59,8 @@
<% end %>
</span>
<link itemprop="mainEntityOfPage" href="<%= post.topic.url %>">
<% if post.image_url %>
<link itemprop="image" href="<%= Discourse.base_url %><%= post.image_url %>">
<% end %>
@ -105,9 +115,8 @@
<% end %>
</div>
<% end %>
<% end %>
</div>
</div>
<% end %>
<% end %>
<% if @topic_view.prev_page || @topic_view.next_page %>